egghead.io_idiomatic_redux_course_notes
egghead.io_idiomatic_redux_course_notes copied to clipboard
VisibleTodoList.js:77 Uncaught TypeError: Cannot read property 'filter' of undefined
did you ever run into an issue with { params } in VisibleTodoList.js?
const mapStateToProps = (state, { params }) => {
console.log('{ params }', { params });
console.log('params', params);
console.log('params.filter', params.filter);
const filter = params.filter || 'all';
return {
todos: getVisibleTodos(state, filter),
filter,
};
};
I keep getting the following error and assume that the first one is related to the second: error1:
warning.js:36 Warning: There is an internal error in the React performance measurement code. Did not expect componentDidMount timer to start while render timer is still in progress for another instance.printWarning @ warning.js:36warning @ warning.js:60beginLifeCycleTimer @ ReactDebugTool.js:123onBeginLifeCycleTimer @ ReactDebugTool.js:234invokeComponentDidMountWithTimer @ ReactCompositeComponent.js:58notifyAll @ CallbackQueue.js:67close @ ReactReconcileTransaction.js:81closeAll @ Transaction.js:204perform @ Transaction.js:146batchedMountComponentIntoNode @ ReactMount.js:127perform @ Transaction.js:138batchedUpdates @ ReactDefaultBatchingStrategy.js:63batchedUpdates @ ReactUpdates.js:98_renderNewRootComponent @ ReactMount.js:321_renderSubtreeIntoContainer @ ReactMount.js:402render @ ReactMount.js:423(anonymous function) @ index.js:23(anonymous function) @ bundle.js:47__webpack_require__ @ bundle.js:20(anonymous function) @ bundle.js:40(anonymous function) @ bundle.js:43
error 2
VisibleTodoList.js:77 Uncaught TypeError: Cannot read property 'filter' of undefined
I figure it's something really stupid but can't find it for the life of me. The console.logs above give me the following...
console.log('{ params }', { params });
{ params } > Object {params: undefined}
params: undefined
>__proto__: Object
console.log('params', params);
params undefined
console.log('params.filter', params.filter);
warning.js:36 Warning: There is an internal error in the React performance measurement code. Did not expect componentDidMount timer to start while render timer is still in progress for another instance.printWarning @ warning.js:36warning @ warning.js:60beginLifeCycleTimer @ ReactDebugTool.js:123onBeginLifeCycleTimer @ ReactDebugTool.js:234invokeComponentDidMountWithTimer @ ReactCompositeComponent.js:58notifyAll @ CallbackQueue.js:67close @ ReactReconcileTransaction.js:81closeAll @ Transaction.js:204perform @ Transaction.js:146batchedMountComponentIntoNode @ ReactMount.js:127perform @ Transaction.js:138batchedUpdates @ ReactDefaultBatchingStrategy.js:63batchedUpdates @ ReactUpdates.js:98_renderNewRootComponent @ ReactMount.js:321_renderSubtreeIntoContainer @ ReactMount.js:402render @ ReactMount.js:423(anonymous function) @ index.js:23(anonymous function) @ bundle.js:47__webpack_require__ @ bundle.js:20(anonymous function) @ bundle.js:40(anonymous function) @ bundle.js:43
VisibleTodoList.js:79 Uncaught TypeError: Cannot read property 'filter' of undefined
someone referenced this todo app in an issue that was created over in the React repository which gaearon said it'd be fixed in the next release, but that doesn't help at the moment...
Yeah I'm getting this bug too. When I run npm install on the lesson branch I get an npm error
No compatible version found: react-router@^3.0.0
Installing an updated version of react-router fixed it for me. If you update your package.json
file with the following line "react-router": "^3.0.0-alpha.1"
, you should no longer see that error.
For anyone using react router 4, the props passed down are { match, location, history }, and you can get params from match (match.params)