reactotron: null is not an object (evaluating 'reduxStore.getState')
I met this error. When I refresh several times, sometimes it runs.
This is my files
// reactoron-config.js
import Reactotron, { trackGlobalErrors } from 'reactotron-react-native';
import apisaucePlugin from 'reactotron-apisauce'; // <--- import
import { reactotronRedux } from 'reactotron-redux';
import sagaPlugin from 'reactotron-redux-saga';
console.tron = Reactotron;
Reactotron
.configure() // we can use plugins here -- more on this later
.use(trackGlobalErrors()) // <--- here we go!
.use(apisaucePlugin())
.use(reactotronRedux())
.use(sagaPlugin())
.connect(); // let's connect!
export default Reactotron;
// configureStore.js
import { applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import thunk from 'redux-thunk';
import Reactotron from '../../env/reactotron-config';
import reducers from '../ducks';
import rootSaga from '../saga';
import googleAnalytics from './middleware/googleAnalytics';
const isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;
const sagaMonitor = Reactotron.createSagaMonitor();
function configureStore(onComplete) {
const sagaMiddleware = createSagaMiddleware({ sagaMonitor });
const store = Reactotron.createStore(reducers, {}, compose(
applyMiddleware(sagaMiddleware, thunk, googleAnalytics),
));
sagaMiddleware.run(rootSaga);
if (isDebuggingInChrome) {
window.store = store;
}
setTimeout(() => {
onComplete(store.getState());
});
return store;
}
// Setup.js
class Setup extends Component {
constructor() {
super();
GoogleAnalytics.setTrackerId('UA-86299762-1');
this.state = {
isLoading: true,
store: configureStore((state) => {
this.setState({ isLoading: false });
if (state.user.nickname) {
const { nickname, school } = state.user;
GoogleAnalytics.setUser(nickname);
setCrashlytics(nickname, school);
}
}),
};
// console.disableYellowBox = true;
}
render() {
if (this.state.isLoading) {
return <LoadingScreen />;
}
return (
<Provider store={this.state.store}>
<App />
</Provider>
);
}
}
RN version: 0.38 reactotron-react-native: 1.6.0 reactotron-redux: 1.6.1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 23 (7 by maintainers)
Commits related to this issue
- chore(deps): update dependency eslint-plugin-react-hooks to v4.0.8 (#317) Co-authored-by: Renovate Bot <bot@renovateapp.com> — committed to infinitered/reactotron by renovate[bot] 4 years ago
- chore(deps): update dependency rollup to v1.32.0 (#317) Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com> — committed to infinitered/reactotron by renovate[bot] 4 years ago
- chore(deps): update jest monorepo to v25.2.1 (#317) Co-authored-by: Renovate Bot <bot@renovateapp.com> — committed to infinitered/reactotron by renovate[bot] 4 years ago
- chore(deps): update dependency prettier to v2.0.4 (#317) Co-authored-by: Renovate Bot <bot@renovateapp.com> — committed to infinitered/reactotron by renovate[bot] 4 years ago
- chore(deps): update dependency prettier to v2.0.5 (#317) Co-authored-by: Renovate Bot <bot@renovateapp.com> — committed to infinitered/reactotron by renovate[bot] 4 years ago
I fixed this flow the document https://github.com/infinitered/reactotron/blob/master/docs/plugin-redux.md
is there any update for this open item? Already try to move it to componentWillMount but still throwing that error only when Reactotron open. Very weird
Calling
.connect()after.createStore()fixed the error for me. I’m not sure if it’s that call order or simply delay calling.connect()solved the problem, but definitely there was a weird race condition in the background.This should be clearly documented.
@skellock That solved it for me. Thanks.
Reactotron setup still happens in my config file, only the
connect()moves to cwm:if (__DEV__) Reactotron.connect();Try moving the
Reactotron.connect()into thecomponentWillMount()of your first component. Same thing?I only changed my code like this.