I have been trying to do a setup using react-native-router-flux and followed the steps. Then tried to follow the examples and also logging a lot of info to try to reverse engineer it to work. However even following all the information I could find I ended up with some weird state structure:
scene is a object containing the router state. However initial state is replicated inside scene (so it contains again devices and rooms objects).
If I change the ordinary state devices or routes it throws an error as: Key <name of the key> has already been defined (other people reporting the same problems here).
So my question is: How do you route your react native apps with redux? Do you use other libraries? Are there any examples or documented resources I could use to fix my code?
Think that it has a typical redux structure. For the sake of the example, this is how it looks on my app/index.js:
import React, { Component } from 'react'
import { Router, Scene } from 'react-native-router-flux'
import { createStore, applyMiddleware, compose } from 'redux'
import { Provider, connect } from 'react-redux'
import logger from 'redux-logger'
import reducers from './reducers'
import Home from './components/home'
import Device from './components/devices'
import Login from './components/login'
const middleware = [logger()]
const store = compose(
applyMiddleware(...middleware)
)(createStore)(reducers)
const RouterWithRedux = connect(reducers)(Router)
export default class AppContainer extends Component {
render () {
return (
<Provider store={store}>
<RouterWithRedux>
<Scene key='login' component={Login} title='Login' />
<Scene key='root' initial={true}>
<Scene key='home' component={Home} title='Home' />
<Scene key='device' component={Device} title='Device' />
</Scene>
</RouterWithRedux>
</Provider>
)
}
}
