Skip to content

Commit

Permalink
docs: update usage.md for react-native 0.72 (#2104)
Browse files Browse the repository at this point in the history
metro.config.js snippet in USAGE.md was outdated, therefore i updated this according the config from react-native-svg-transformer.
  • Loading branch information
Letty committed Aug 1, 2023
1 parent 34243a5 commit 9cd8280
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,34 @@ Try [react-native-svg-transformer](https://github.com/kristerkari/react-native-s
<https://github.com/kristerkari/react-native-svg-transformer#installation-and-configuration>
<https://github.com/kristerkari/react-native-svg-transformer#for-react-native-v057-or-newer--expo-sdk-v3100-or-newer>

`metro.config.js`
`metro.config.js` for react-native >= 0.72

```js
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");

const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;

/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve("react-native-svg-transformer")
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== "svg"),
sourceExts: [...sourceExts, "svg"]
}
};

module.exports = mergeConfig(defaultConfig, config);
```

`metro.config.js` for react-native < 0.72

```js
const { getDefaultConfig } = require('metro-config');
Expand Down

0 comments on commit 9cd8280

Please sign in to comment.