@@ -41,10 +41,12 @@ react-native run-ios
4141yarn add babel-plugin-react-native-classname-to-dynamic-style babel-plugin-react-native-platform-specific-extensions react-native-css-transformer --dev
4242```
4343
44- ### Step 4: Setup your project's ` .babelrc `
44+ ### Step 4: Setup your project's Babel configuration
4545
4646#### For React Native v0.57 or newer
4747
48+ ` .babelrc `
49+
4850``` json
4951{
5052 "presets" : [" module:metro-react-native-babel-preset" ],
@@ -64,6 +66,8 @@ yarn add babel-plugin-react-native-classname-to-dynamic-style babel-plugin-react
6466
6567#### For React Native v0.56 or older
6668
69+ ` .babelrc `
70+
6771``` json
6872{
6973 "presets" : [" react-native" ],
@@ -79,9 +83,28 @@ yarn add babel-plugin-react-native-classname-to-dynamic-style babel-plugin-react
7983}
8084```
8185
86+ ---
87+
88+ #### For Expo
89+
90+ ` babel.config.js ` (older Expo versions use ` .babelrc ` )
91+
92+ ``` js
93+ module .exports = function (api ) {
94+ api .cache (true );
95+ return {
96+ presets: [" babel-preset-expo" ],
97+ plugins: [
98+ " react-native-classname-to-dynamic-style" ,
99+ [" react-native-platform-specific-extensions" , { extensions: [" css" ] }]
100+ ]
101+ };
102+ };
103+ ```
104+
82105### Step 5: Setup ` rn-cli.config.js ` in your project
83106
84- #### For React Native v0.57 or newer
107+ #### For React Native v0.57 or newer / Expo SDK v31.0.0 or newer
85108
86109Add this to ` rn-cli.config.js ` in your project's root (create the file if you don't have one already):
87110
@@ -103,11 +126,23 @@ module.exports = (async () => {
103126})();
104127```
105128
129+ If you are using [ Expo] ( https://expo.io/ ) , you also need to add this to ` app.json ` :
130+
131+ ``` json
132+ {
133+ "expo" : {
134+ "packagerOpts" : {
135+ "config" : " rn-cli.config.js"
136+ }
137+ }
138+ }
139+ ```
140+
106141---
107142
108143#### For React Native v0.56 or older
109144
110- Add this to ` rn-cli.config.js ` in your project's root (create the file if you don't have one already):
145+ If you are using React Native without Expo, add this to ` rn-cli.config.js ` in your project's root (create the file if you don't have one already):
111146
112147``` js
113148module .exports = {
@@ -120,7 +155,9 @@ module.exports = {
120155};
121156```
122157
123- ...or if you are using [ Expo] ( https://expo.io/ ) , in ` app.json ` :
158+ #### Expo SDK v30.0.0 or older
159+
160+ If you are using [ Expo] ( https://expo.io/ ) , instead of adding the ` rn-cli.config.js ` file, you need to add this to ` app.json ` :
124161
125162``` json
126163{
0 commit comments