React-router - how to use route params in onEnter?

前端 未结 1 1749
太阳男子
太阳男子 2021-02-13 06:59

I want to do a fetch using the onEnter callback, but I don\'t know how to read a URL param in the Route component. I have this Route



        
1条回答
  •  渐次进展
    2021-02-13 07:48

    Nevermind, it was trivial.

    
    
    export function onBookLoad(nextState) {
     console.log(nextState.params.bookId);
     //do stuff with the param
    }
    

    0 讨论(0)
提交回复
热议问题