Skip to content

Commit 3441a68

Browse files
authored
Update react-native.md
1 parent 5940f33 commit 3441a68

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

articles/communication-services/quickstarts/chat/react-native.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,23 @@ After you [initialize your React Native project](https://reactnative.dev/docs/en
4444
npm install react-native-url-polyfill --save-dev
4545
```
4646

47-
1. Update _metro.config.js_ to use React Native-compatible Node Core modules:
47+
1. Create or update the _metro.config.js_ file in the same directory as your _app.js_ file to configure React Native-compatible Node Core modules. If the file doesn’t exist, create a new one with the following content:
4848

4949
```javascript
50-
module.exports = {
51-
// ...
52-
resolver: {
53-
extraNodeModules: {
54-
...require('stream-browserify'),
55-
...require('node-libs-react-native'),
56-
net: require.resolve('node-libs-react-native/mock/net'),
57-
tls: require.resolve('node-libs-react-native/mock/tls')
58-
}
50+
// metro.config.js
51+
52+
const { getDefaultConfig } = require('expo/metro-config');
53+
54+
const config = getDefaultConfig(__dirname);
55+
56+
config.resolver.extraNodeModules = {
57+
...require('node-libs-react-native'),
58+
stream: require.resolve('stream-browserify'),
59+
net: require.resolve('node-libs-react-native/mock/net'),
60+
tls: require.resolve('node-libs-react-native/mock/tls'),
5961
};
60-
}
62+
63+
module.exports = config;
6164
```
6265

6366
1. Add the following `import` commands at the top of your entry point file:

0 commit comments

Comments
 (0)