Closed morgs32 closed 4 years ago
The this in the match function is undefined unless I do
this
const matchSelector = memoizeOne(routes.match.bind(routes))
And the reason I'm having to use the memoizer is because match returns a new object every time it runs, which will cause the component to render on every state change.
match
export const mapStateToProps = () => { console.log('routes.match', routes.match); const matchSelector = memoizeOne(routes.match.bind(routes)) // const repoSelector = createResourceSelector() // return (state, props) => { // // const { // router, // } = props // // const match = matchSelector(router.asPath) // const repoSelector = createResourceSelector() return (state, props) => { const { router, } = props console.log('routes', routes); console.log('router.asPath', router.asPath); console.log('matchSelector(router.asPath)', matchSelector(router.asPath)); const match = routes.match(router.asPath) return { match, repo: repoSelector(state, { id: props.router.query.repoId, type: 'repos', }) } } }
The
this
in the match function is undefined unless I doAnd the reason I'm having to use the memoizer is because
match
returns a new object every time it runs, which will cause the component to render on every state change.