react-redux-realworld-example-app
react-redux-realworld-example-app copied to clipboard
Unhandled Rejection (TypeError): Cannot read property '0' of null
I cloned the current state of this repo and directly started it:
npm install
npm start
And directly get this error:
Unhandled Rejection (TypeError): Cannot read property '0' of null
./src/reducers/articleList.js.__webpack_exports__.a
C:/dev/Aufgabe/FeatureImage/react-redux-realworld-example-app/src/reducers/articleList.js:53
50 | return {
51 | ...state,
52 | pager: action.pager,
> 53 | tags: action.payload[0].tags,
54 | articles: action.payload[1].articles,
55 | articlesCount: action.payload[1].articlesCount,
56 | currentPage: 0,
This error comes from this commit: #105
Reverting "react-scripts"
to "0.9.5"
helps
"react-scripts": "0.9.5"
Hi I reverted to "0.9.5", the application won't crash. However, the items (comments, tags) cannot load. Always stay in "Loading". Any thought?
@Taroka I don't think that is related to this issue.
@Spenhouet @Taroka
In ~\src\components\Home\index.js change line 37 from:
this.props.onLoad(tab, articlesPromise, Promise.all([agent.Tags.getAll(), articlesPromise()]));
to
Promise
.all([agent.Tags.getAll(), articlesPromise()])
.then((result) => {
this.props.onLoad(tab, articlesPromise, result);
});
The issue is the promise is being passed to the reducer before the API calls have finished. Ideally, that would be in a thunk so the component isn't making API calls directly (nor do you run into this particular issue). But it looks like that is done everywhere.
I'm not sure if this is the correct fix since I assume this has been working for some time since that line hasn't changed in a year. But this should help you work around the issue until someone more knowledgeable with the code base can do a true fix.
Hope this helps.
@Spenhouet After changing the scripts version, it shows no error but is forever loading! Are you using django backend?