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

后端 未结 4 2082
遥遥无期
遥遥无期 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:25

    The the state property of the to prop is the param of pushState method of History DOM object described here

    That props used in push/replace methods of router as described here for transitions to a new URL, adding a new entry in the browser history like this:

    router.push('/users/12')
    
    // or with a location descriptor object
    router.push({
      pathname: '/users/12',
      query: { modal: true },
      state: { fromDashboard: true }
    })
    

    It also mentioned here:

    router.push(path)
    router.push({ pathname, query, state }) // new "location descriptor"
    
    router.replace(path)
    router.replace({ pathname, query, state }) // new "location descriptor"
    

提交回复
热议问题