What is a state in <Link> component of React Router?

后端 未结 4 2099
遥遥无期
遥遥无期 2021-01-04 12:11

Here is a screenshot from their docs about component

  1. What state do they mean? A Redux state?
4条回答
  •  长发绾君心
    2021-01-04 12:15

    In simple term state in component is use to pass information from one view to other view through router in form of object.On other page it can be access using prop.location.state.

    (Note: on browser refresh state no longer contain information)

    To pass state in Link:

    
    

    To access id in second page view:

    let id = props.location.state.id;
    

    For more Link properties : React Router Link

提交回复
热议问题