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

前端 未结 1 760
無奈伤痛
無奈伤痛 2021-02-13 07:18

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:22

    Nevermind, it was trivial.

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

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