[React] routing component jump page and storage parameters

Record more comfortable way currently used:

1, Jump

<Button type="secondary" size='small'  >
              <Link to={{ pathname: '/base/strategyList',search:id+'', query: {sceneId:id,record:record} }}>查看</Link>
            </Button>&nbsp;

2, get the value:

  componentDidMount () { 
    const {dispatch, LOCATION} = the this .props; 

    the let recvParam; 

    IF (location.query && location.query.record) { // Analyzing parameters currently 
      recvParam = location.query.record; 
      sessionStorage.setItem ( 'Data' , recvParam); // stored into the sessionStorage 
    } the else { 
      recvParam = sessionStorage.getItem ( 'Data'); // when no state parameters, the parameters taken sessionStorage 
    } 

    the this .setState ({ 
      recvParam 
    }) 

    the console.log ( "recvParam" , recvParam) 
  }

 

Guess you like

Origin www.cnblogs.com/the-fool/p/11365425.html