Skip to content
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

Update redux instructions in README #570

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,55 @@ export default combineReducers({

##### Step 3

Create a routes

```js
// routes.js
import React from 'react-native'
import {
Scene,
Switch,
Modal,
Router
} from 'react-native-router-flux'
import { connect } from 'react-redux'

// other imports...

const RouterWithRedux = connect()(Router)

class Routes extends React.Component {

render () {
return (
<RouterWithRedux>
<Scene key="root">
<Scene key="login" component={Login} title="Login"/>
<Scene key="register" component={Register} title="Register"/>
<Scene key="home" component={Home}/>
</Scene>
</RouterWithRedux>
);
}
}

export default Routes

```

##### Step 4

Create your store, wrap your routes with the redux `Provider` component and connect your Router


```js
// app.js

import { Router } from 'react-native-router-flux';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, compose, connect } from 'redux';
import { createStore, applyMiddleware, compose } from 'redux';

const RouterWithRedux = connect()(Router);
import reducers from './reducers';
import Routes from './routes'
// other imports...

// create store...
Expand All @@ -316,12 +353,10 @@ const store = compose(


class App extends React.Component {
render () {
render() {
return (
<Provider store={store}>
<RouterWithRedux>
// your scenes here
</RouterWithRedux>
<Routes />
</Provider>
);
}
Expand All @@ -330,7 +365,8 @@ class App extends React.Component {
export default App;
```

##### Step 4

##### Step 5

Now you can access the current scene from any connected component.

Expand Down