componentWillReceiveProps not firing

前端 未结 4 2183
醉梦人生
醉梦人生 2021-02-18 12:51

In my other classes, componentWillReceiveProps was working nicely, but for some reason, it isn\'t firing here.

ItemView.jsx

class ItemView extends React.         


        
4条回答
  •  猫巷女王i
    2021-02-18 13:33

    i also had the same problem. if someone typed in a direct url the componentwillreceiveprops did not fire. i had to refactor my code as well to get it all working.

    Changes i made was in my initial index.tsx having something like (i.e. have the router as the outer element):

    render( 
    
    {routes}
    
    , document.getElementById('root'));

    my default route was to my app.tsx page with a structure as follows: render() {

    return (
     
       
    {this.props.children}
    );

    }

提交回复
热议问题