A web replacement for react-native-svg
npm install react-native-svg-webThis package can be used as a drop-in replacement for react-native-svg when targeting the web, or as a mock for jest when testing react-native applications.
Add the following to your webpack configuration:
`` javascript
module.exports = {
..., / the existing configuration /
resolve: {
alias: {
'react-native-svg': 'react-native-svg-web'
}
}
};
`
Add the following to your package.json.
` json`
{
"jest": {
"setupFiles": [
"./jest/mocks/react-native-svg.js"
]
}
};
And then create a file ./jest/mocks/react-native-svg.js:
` javascript``
jest.mock('react-native-svg', () => require('react-native-svg-web'));