bakerface / react-native-svg-web

A web replacement for react-native-svg
44 stars 11 forks source link

Use import/export syntax and use createElement from react-native-web #3

Closed EyMaddis closed 4 years ago

EyMaddis commented 5 years ago

This aligns the project with other React-Native packages and allows to use the style behavior of React-Native-Web (StyleSheet.create).

joan-saum commented 4 years ago

Hey @EyMaddis , it looks like @bakerface appeared recently, so if you resolve the conflict, the PR could be merged :)

EyMaddis commented 4 years ago

@joan-saum @bakerface Is up to date :)

bakerface commented 4 years ago

@EyMaddis thank you for the pull request, this has been released to v1.0.3

i2xzy commented 4 years ago

I'm getting this error:

ERROR in ./node_modules/react-native-svg-web/index.js 103:13
Module parse failed: Identifier 'Svg' has already been declared (103:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| Svg.Stop = Stop;
| 
> export const Svg = createElement("Svg", "svg");
| Svg.Svg = Svg;
| 

Looks like the problem is this line was added:

Svg.Svg = Svg; // stay consistent with the old require based api

But it didn't need to be as the original author already included Svg as a named export:

Svg.Svg = createElement('Svg', 'svg');

which was changed to this in the pr:

export const Svg = createElement("Svg", "svg");
Svg.Svg = Svg;
EyMaddis commented 4 years ago

Sorry to both of you. Should be fixed in https://github.com/bakerface/react-native-svg-web/pull/9 Since I don't actually use the library right now I did not properly test... Shame on me.

i2xzy commented 4 years ago

ok I'm getting a different error now:

WARNING in ./node_modules/react-native-svg-web/index.js 29:11-26
"export 'createElement' (imported as 'RNcreateElement') was not found in 'react-native-web'
EyMaddis commented 4 years ago

This depends on the react-native-web version. In the latest the import was renamed to unstable_createElement.. Here is the way react-native-svg solves this: https://github.com/react-native-community/react-native-svg/blob/develop/src/ReactNativeSVG.web.ts#L14

i2xzy commented 4 years ago

Probably best to do it that way to stay backwards compatible