Skip to content

Commit

Permalink
Document Expo SDK v39 behavior
Browse files Browse the repository at this point in the history
Fixes ai#207
  • Loading branch information
ctavan committed Dec 1, 2020
1 parent a6f1f69 commit d859624
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ Use Nano ID 2 `npm i nanoid@^2.0.0` until Create React App 4.0 release.

### React Native

React Native does not have built-in random generator.
React Native does not have built-in random generator. The following polyfill works for plain React
Native and Expo starting with v39.

1. Check [`react-native-get-random-values`] docs and install it.
2. Import it before Nano ID.
Expand Down Expand Up @@ -268,7 +269,7 @@ For Rollup you will need [`@rollup/plugin-replace`] to replace

### Expo

If you use Expo in React Native, you need a different workaround.
If you use Expo prior to v39 in React Native, you need a different workaround.

1. Install [`expo-random`](https://www.npmjs.com/package/expo-random).
2. Use `nanoid/async` instead of `nanoid`.
Expand Down
2 changes: 1 addition & 1 deletion index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== 'production') {
'React Native does not have a built-in secure random generator. ' +
'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
'For secure IDs, import `react-native-get-random-values` ' +
'before Nano ID. If you use Expo, install `expo-random` ' +
'before Nano ID. If you use Expo v38 or below, install `expo-random` ' +
'and use `nanoid/async`.'
)
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@
"Rollup",
"transpile",
"workaround",
"Deno"
"Deno",
"polyfill",
"v39"
]
},
"sharec": {
Expand Down

0 comments on commit d859624

Please sign in to comment.