Update React Native installation instructions
Emilios1995 opened this issue · 32 comments
Seems that React Native works on top of react already. the issue facebook/react-native#2985 is already closed.
Can we already use React-Redux 4?
That change is not in the released version yet. In few days I guess...
The change is included in the newly released 0.18-rc (I haven't tested it with redux 4 yet), so hopefully not long to go!
OK, I got react-redux 4.0.6
to work with react-native
, it will be available in example-react-native-redux.
There are couple of steps need to be done which I hide them at the moment in package.json
's postscript
. Here's the details:
react
module inreact-native/node_module
must be deleted.fbjs
module inreact-native/node_modules
must be deleted.fbjs
module inreact/node_modules
must be deleted.fbjs
module must be added as module to project in mainpackage.json
all .babelrc
files must be deleted under node_module folder
There is a discussion here facebook/react-native#2985 (comment) which @spicyj talks about changing fbjs.
Also @gaearon I still need to remove all .babelrc files under node_modules before I can run the example-react-native-redux. What is your suggestion?
Before checking anything I just replaced import { connect } from 'react-redux/native'
with import { connect } from 'react-redux'
. Also updated the following:
import { Provider } from 'react-redux/native';
...
<Provider store={store}>
{() => <App/>}
</Provider>
TO:
import { Provider } from 'react-redux';
...
<Provider store={store}>
<App/>
</Provider>
I use the most recent version of react-redux
:
"react-native": "^v0.18.0-rc",
"react-redux": "^4.0.6",
"redux": "^3.0.5",
I didn't need to change anything in the react-redux
package. It just works, as expected by a tool from @gaearon ;-)
In npm 2.x, if you define peerDependencies, it will install it in your root node_modules. react-redux
has a peerDependency to react
and react-native has react
module. if you start the app using react-native start
, haste
will throw an exception that fbjs
on react
has a conflict with fbjs
in react-native
. @Purii I would like to see an example from you. Would you create a repo and upload an example?
Maybe if we make react
and fbjs
peer deps of RN that'll help?
@spicyj That's an interesting idea. Making react a peer dep sounds like it could be semantically correct. I think it's probably more correct that fbjs is a normal dependency though, and RN 0.19 may address the issue with conflicting fbjs modules with some patches that are being reviewed. (Alternatively npm3 fixes this too.)
@Purii That should be it, since npm@3
promises flat node_modules
. The only issue is that, not all modules in npmjs
are compatible with npm@3
. Thanks though for letting me know
It works for me with npm@3
I think it's safer to modify the instructions if/after react-native
is a peer of react
.
@spicyj Plans to make this happen?
Send a PR? Should be pretty simple.
For those here looking for a solution for react-redux
, everything is working great for me with react-native-0.19.0-rc
and npm3
, but definitely not with npm2
.
The fbjs commits didn't make it into 0.19 so stay tuned for 0.20 or 0.21.
To be fair, the problems at this point that result from using react-native@0.18 and react-redux@4 are entirely bugs within the dependency resolver the react-native bundle operation performs. They are in no way unique to react-redux. They do go away with npm@3; because, it no longer has the duplicate dependencies.
@zuk @alinz How did it work for you guys?
This is the error I get:
Unable to resolve module react from /Users/ranyefet/Code/yesno/ios-app/node_modules/react-redux/lib/components/Provider.js: Invalid directory /Users/node_modules/react
I'm using NPM3 with these dependencies:
"react-native": "^0.19.0",
"redux": "^3.2.1",
"react-redux": "^4.2.1",
I don't have react
dependency in my package.json (should I have?)
Please anyone help :)
Yes, you’d need to depend on react
. When you do, make sure to delete node_modules/react-native/node_modules/react
so you don’t end up with two of them.
@gaearon Thanks Dan, looks like it's working :)
But, now I get a different error:
Unable to resolve module LinkedStateMixin from /Users/ranyefet/Code/yesno/ios-app/node_modules/react-native/Libraries/react-native/react-native.js: Invalid directory /Users/node_modules/LinkedStateMixin
Which seems there's no solution yet :(
Unfortunately I can’t really help you with this! Hopefully this will be fixed.
Yeah I know it's not related to this repo, just ranting 😞
Thanks anyway!
@ranyefet we do have react@0.14.5
as our dependency in our project. make sure to delete node_modules folder and try again. and here is my react-native module as a reference.
my npm version is 3.6.0
my node version is v5.5.0
So, what's going on? Are we still waiting for react-native to be a peer of react?
If anyone encountered same problems, here is a way worth to try:
- DELETE FULL node_module directory
- edit you package.json, react-native@19 and react-redux@4
- make sure your npm@3
- npm install
with a refreshed install and see if it works
So, what's going on? Are we still waiting for react-native to be a peer of react?
Yes. AFAIK it is already the case in master. Just waiting for the next release.
Good! But wasn't it included in 0.20? @gaearon do you recommend reinstalling the modules to make it work right now?
Still appears to be a dependency in 0.20: https://github.com/facebook/react-native/blob/6496feb61e9205baa3f25cf448c4fce912bd6250/package.json#L136
cc @skevy
@gaearon working on it :) We'll know by Friday if "React as as a peer dep" is going to make it into the 0.21-RC branch cut.
Thanks for the ping. Trust me, we're working hard to get this stuff worked out and make React Native a better member of the general React ecosystem.
I have no doubts about your efforts, thank you very much for working on this!
The note in README now says you can use react-redux@4.x
just fine. I’ll add a clarification that you should be careful to avoid ending up with two react
s.