react-native-svg-web
react-native-svg-web copied to clipboard
Does react-native-svg work for the web?
I have just opened those issues:
- https://github.com/expo/expo/issues/6660
- https://github.com/react-native-community/react-native-svg/issues/1235
It seems that react-native-svg is already for the web, but it does not work for me.
Every component imported in the web are just path and not react component.
Do I need this plugin ? If yes, how do I include it in expo ?
If you are using webpack you can try this solution
https://github.com/react-native-svg/react-native-svg/issues/1478
Hi @KEMBL! Thanks for your webpack solution. My webpack config is like this and I do alias like below. Now I'm a bit confused about how should I configure my webpack now. Could you please help me solve it
module.exports = function override(config, env) {
// allow importing from outside of src folder
config.resolve.plugins = config.resolve.plugins.filter(
plugin => plugin.constructor.name !== 'ModuleScopePlugin'
)
/** alias-parrt **/
config.resolve.alias['react-native-linear-gradient'] = 'react-native-web-linear-gradient'
/** alias-parrt **/
config.module.rules[0].include = appIncludes
config.module.rules[1] = null
config.module.rules[2].oneOf[1].include = appIncludes
config.module.rules[2].oneOf[1].options.plugins = [
require.resolve('babel-plugin-react-native-web'),
].concat(config.module.rules[2].oneOf[1].options.plugins)
config.module.rules = config.module.rules.filter(Boolean)
config.plugins.push(
new webpack.DefinePlugin({ __DEV__: env !== 'production' })
)
return config
}
I fixed it in this way as you said
config.resolve.alias['react-native-svg'] = aliasPathJoin(['react-native-svg', 'lib', 'module', 'ReactNativeSVG.web.js'])
the problem in my svgs was the style attribute which I removed and everything works fine