Skip to content

[fix] Import react-art only client side to avoid crash #838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

anonkey
Copy link

@anonkey anonkey commented Feb 27, 2018

Little fix to avoid crash on server side rendering

@necolas
Copy link
Owner

necolas commented Feb 27, 2018

This isn't a reliable approach. There's a fix upstream that I'm hoping will make it into the 16.3 react releases

@necolas necolas closed this Feb 27, 2018
@koulmomo
Copy link
Contributor

@anonkey you can avoid the crash by using https://www.npmjs.com/package/babel-plugin-react-native-web along with making sure you never import all of React Native and only using named imports instead.

// never do this
import ReactNative from 'react-native';

// do this instead
import {View, Text} from 'react-native';

The downside is that you will have to run transpiled code on the server.

@necolas
Copy link
Owner

necolas commented Feb 27, 2018

I don't know when the next react release will fix this. So actually I'll reopen this and consider a temporary fix. May also make 'react-art' a peer dependency like the other react packages

@necolas necolas reopened this Feb 27, 2018
@anonkey
Copy link
Author

anonkey commented Feb 28, 2018

@koulmomo Thanks a lot, but it doesn't work for me ATM i'll investigate
EDIT: ok just a little webpack config to do thanks for your trick.
@necolas Yes i didn't think about it, it seem a good idea.

@necolas
Copy link
Owner

necolas commented Apr 4, 2018

Art has been updated and this issue should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants