Cannot read property ‘params’ of undefined (React Router 4)

后端 未结 6 704
甜味超标
甜味超标 2020-12-29 04:49

I have a route set up to render a component:



        
6条回答
  •  [愿得一人]
    2020-12-29 05:17

    The error says the match prop is undefined. That's correct, there is no match prop here:

    
    

    So we need to pass it in. The render function receives a bunch of props from react-router, and all of them need to be passed further down. So, spread them first, and then add your own props:

     (
        
      )}
    />
    

提交回复
热议问题