0

Currently in my code I need to pass a value from one component to the other through a button using router link .. I am able to do this, but this value is appearing in the URL, appearing as if I had sent a GET. I want to be able to pass this value on to the other component in a hidden way.

See the important parts of my code:

In TotalCartComponent:

<Link to={"/orderproduct/" + total}>ADVANCE</Link> 

In OrderProduct:

   <h1>HELLO!!</h1>
   <h4>Total is: {this.props.match.params.total}</h4>

In AppShell:

 <main>
     <Switch>
            <Route exact path="/" component={Main}/>
            <Route path="/mycart" component={MyCart}/>            
            <Route path="/orderproduct/:total"  component={OrderProduct}/>
            <Route path="/view1" component={View1}/>
     </Switch>
 </main>
Willian
  • 21
  • 1
  • 5
  • What about if you pass the param in base64 format? – Saul Ramirez Jul 24 '20 at 19:26
  • I'd recommend `location.state` – Dane Jul 24 '20 at 19:28
  • I saw that it had this state, but I couldn't pass it and redeem it on OrderProduct Do you have any functional example using this router link and passing the parameter with the state? – Willian Jul 24 '20 at 21:14
  • Hi, I managed to pass a hidden parameter through the state! I just had to change the link In this way: https://stackoverflow.com/questions/41466055/how-do-i-pass-state-through-react-router Thanks to all for your help! – Willian Jul 26 '20 at 14:51

0 Answers0