I want my button to:
- first trigger a POST request with its
onClick
callback - then navigate to another page using react-router facilities
I have proposals for each case.
This is how I can achieve the callback handling:
<button onClick={handleSubmitfunc}>Submit</button>
This is how I see the navigation:
<Link to='/secondpage' state={{from: variable}}>Submit</Link>
My code below tries to resume the two requierements, but doesn't achieve the goal. Only the callback is triggered but not the navigation:
<Link
to="/secondpage"
onClick={handleSubmitfunc}
state={{from: email}}>
Clickable Link
</Link>
Does the combination fail because I have a state prop?
For reference, I've seen the issue before in: How to use onClick event on react Link component?. That didn't help much.