I am having problems running my app, specifically on Android at the moment. When I run react-native run-android and start the app (with or without running react-native start beforehand) I get the following error: Undefined is not an object (evaluating 'root._'). I am then unable to launch the debugger because this gives me a timeout whilst connecting to remote debugger error.
My loading process for the application is as follows: index.js:
import { AppRegistry } from 'react-native'
import setup from './src/setup'
AppRegistry.registerComponent('appname', setup)
setup.js:
import React, { Component } from 'react'
import { View } from 'react-native'
import { Provider } from 'react-redux'
import { AsyncStorage } from 'react-native'
import { persistStore } from 'redux-persist';
import configureStore from './store/configureStore'
import Spinner from './components/common/Spinner'
import App from './App'
import styles from './styles/setup'
export class Root extends Component {
constructor() {
super()
this.state = {
loaded: false,
// store: configureStore(this.onStoreLoaded.bind(this))
}
}
onStoreLoaded() {
this.setState({
loaded: true,
})
}
render() {
return (
<View style={styles.wrapper}>
<Spinner/>
</View>
)
}
}
export default function setup() {
return Root
}
I have commented out the store loading for now because this seems to have become apparent since adding redux but the configure store looks as follows:
import {applyMiddleware, createStore, compose} from 'redux'
import {persistStore, autoRehydrate} from 'redux-persist';
import { AsyncStorage } from 'react-native'
import thunk from 'redux-thunk'
import reducers from '../reducers'
const middlewares = [
thunk
]
const store = createStore(
reducers,
undefined,
compose(
applyMiddleware(...middlewares),
autoRehydrate()
)
)
export default function(callback) {
persistStore(store, {
blacklist: [],
storage: AsyncStorage
}, callback)
return store
}
I am using react-native 0.53.0 with the redux version being 3.7.2 and react-redux 5.0.6. I have tried re bundling the code as follows:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
I have also tried: adb reverse tcp:8081 tcp:8081
I have also updated my build tools and gradle etc in Android studio and everything syncs fine.