Skip to content

Commit

Permalink
Merge pull request #4 from kanzitelli/web-support
Browse files Browse the repository at this point in the history
Web support
  • Loading branch information
kanzitelli committed Dec 15, 2021
2 parents 9018917 + 1acfa58 commit 6a3dfd0
Show file tree
Hide file tree
Showing 7 changed files with 3,743 additions and 90 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<img src="https://xxx-files.ggc.team/oss/rn-bounceable/logo.png" width="80%" title="Logo">
</p>


## Quick start

```bash
Expand All @@ -26,6 +25,36 @@ class Screen = () => {
}
```

### Expo Web

Since `rn-bounceable` uses Reanimated 2, we need its babel plugin to be applied. Expo Web doesn't transpile modules by default, so we'll need to tell it to transpile the library.

1. Install `@expo/webpack-config`:

```
yarn add -D @expo/webpack-config
```

2. Create `webpack.config.js` in the root of your project:

```
const createExpoWebpackConfigAsync = require('@expo/webpack-config')
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(
{
...env,
babel: { dangerouslyAddModulePathsToTranspile: ['rn-bounceable'] },
},
argv
)
return config
}
```

Don't forget to add `webpack.config.js` into `tsconfig.json` under `exclude` section, if needed.

##### Available props

```tsx
Expand All @@ -47,7 +76,7 @@ type BounceableProps = {

Examples could be found in `expo-example` folder or in [expo-starter](https://github.com/kanzitelli/expo-starter), [rn-starter](https://github.com/kanzitelli/rn-starter) and [rnn-starter](https://github.com/kanzitelli/rnn-starter).

See it in Expo Go - https://expo.io/@kanzitelli/rn-bounceable-example.
See it with [Expo Web](https://rn-bounceable.batyr.io) or [Expo Go](https://expo.io/@kanzitelli/rn-bounceable-example).

This library was bootstrapped from [kanzitelli/if-component](https://github.com/kanzitelli/if-component).

Expand Down
1 change: 1 addition & 0 deletions expo-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@expo/webpack-config": "^0.16.13",
"@types/react": "~17.0.21",
"@types/react-native": "~0.64.12",
"tslib": "^2.3.1",
Expand Down
13 changes: 13 additions & 0 deletions expo-example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const createExpoWebpackConfigAsync = require('@expo/webpack-config');

module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(
{
...env,
babel: {dangerouslyAddModulePathsToTranspile: ['rn-bounceable']},
},
argv,
);

return config;
};
Loading

0 comments on commit 6a3dfd0

Please sign in to comment.