Skip to content

Commit 176e57b

Browse files
committed
chore: update readme
1 parent 91df718 commit 176e57b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,17 @@ try {
188188

189189
## React Native
190190

191-
BSON requires that `TextEncoder`, `TextDecoder`, `atob`, `btoa`, and `crypto.getRandomValues` are available globally. These are present in most Javascript runtimes but require polyfilling in React Native. Polyfills for the missing functionality can be installed with the following command:
191+
BSON vendors the required polyfills for `TextEncoder`, `TextDecoder`, `atob`, `btoa` when using React Native. One
192+
additional polyfill, `crypto.getRandomValues` is required and can be installed with the following command:
193+
192194
```sh
193-
npm install --save react-native-get-random-values text-encoding-polyfill base-64
195+
npm install --save react-native-get-random-values
194196
```
195197

196198
The following snippet should be placed at the top of the entrypoint (by default this is the root `index.js` file) for React Native projects using the BSON library. These lines must be placed for any code that imports `BSON`.
197199

198200
```typescript
199201
// Required Polyfills For ReactNative
200-
import {encode, decode} from 'base-64';
201-
if (global.btoa == null) {
202-
global.btoa = encode;
203-
}
204-
if (global.atob == null) {
205-
global.atob = decode;
206-
}
207-
import 'text-encoding-polyfill';
208202
import 'react-native-get-random-values';
209203
```
210204

@@ -214,7 +208,7 @@ Finally, import the `BSON` library like so:
214208
import { BSON, EJSON } from 'bson';
215209
```
216210

217-
This will cause React Native to import the `node_modules/bson/lib/bson.cjs` bundle (see the `"react-native"` setting we have in the `"exports"` section of our [package.json](./package.json).)
211+
This will cause React Native to import the `node_modules/bson/lib/bson.rn.cjs` bundle (see the `"react-native"` setting we have in the `"exports"` section of our [package.json](./package.json).)
218212

219213
### Technical Note about React Native module import
220214

0 commit comments

Comments
 (0)