Skip to content
Myr

Remove old Expo advice

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent 48b9877 · Browse files · 4 files+6 added−28 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+6 added−28 removed

  • tests:+1 added−1 removed
  • other:+5 added−27 removed

4 files+6 added−28 removed

modified:test/async.test.js+1 added-1 removed
modified:index.browser.js+1 added-2 removed
12 unmodified lines
13 throw new Error(14 'React Native does not have a built-in secure random generator. ' +15 'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +16 'For secure IDs, import `react-native-get-random-values` ' +17 'before Nano ID. If you use Expo v38 or below, install `expo-random` ' +18 'and use `nanoid/async`.'17 'before Nano ID.'18 )19 }20 if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {21 throw new Error(
83 unmodified lines
modified:package.json+2 added-3 removed
72 unmodified lines
73 },74 {75 "name": "customAlphabet",76 "import": "{ customAlphabet }",77 "limit": "142 B"77 "limit": "141 B"78 },79 {80 "name": "urlAlphabet",81 "import": "{ urlAlphabet }",
105 unmodified lines
187 "Rollup",188 "transpile",189 "workaround",190 "Deno",191 "polyfill",192 "v39"191 "polyfill"192 ]193 },194 "sharec": {195 "config": "@logux/sharec-config",
3 unmodified lines
modified:README.md+2 added-22 removed
45 unmodified lines
46 * [React](#react)47 * [Create React App](#create-react-app)48 * [React Native](#react-native)49 * [Rollup](#rollup)50 * [Expo](#expo)50 * [PouchDB and CouchDB](#pouchdb-and-couchdb)51 * [Mongoose](#mongoose)52 * [ES Modules](#es-modules)53 * [Web Workers](#web-workers)
179 unmodified lines
233234235### React Native236238React Native does not have built-in random generator. The following polyfill works for plain React239Native and Expo starting with v39.237React Native does not have built-in random generator. The following polyfill238works for plain React Native and Expo starting with `39.x`.2392401. Check [`react-native-get-random-values`] docs and install it.2412. Import it before Nano ID.242
22 unmodified lines
265266[`@rollup/plugin-replace`]: https://github.com/rollup/plugins/tree/master/packages/replace267268270### Expo271272If you use Expo prior to v39 in React Native, you need a different workaround.2732741. Install [`expo-random`](https://www.npmjs.com/package/expo-random).2752. Use `nanoid/async` instead of `nanoid`.2763. Import `index.native.js` file directly.277278```js279import { nanoid } from 'nanoid/async/index.native'280281async function createUser () {282 user.id = await nanoid()283}284```285286[`expo-random`]: https://www.npmjs.com/package/expo-random287288269### PouchDB and CouchDB270271In PouchDB and CouchDB, IDs can’t start with an underscore `_`.272A prefix is required to prevent this issue, as Nano ID might use a `_`
212 unmodified lines