I'm trying to get my button to navigate to an edit page for Server information I'll be providing to the route with Redux. This is written with typescript too, if that makes a difference?
I've gotten it to work if I wrap the button text like so:
<button onClick={this.handleEditCurrentServer}>
<Link to={`/servers/${encodeURIComponent(this.props.IServer.name)}/edit`}>
Edit
</Link>
</button>
But the problem is that I don't want the text to be what's clicked, I want the whole button to be clickable for this route to work.
So I've tried it like this:
<Link to={`/servers/${encodeURIComponent(this.props.IServer.name)}/edit`}>
<button onClick={this.handleEditCurrentServer}>
Edit
</button>
</Link>
But unfortunately it's not using the link anymore. Is there a way to possibly add to the buttons onClick attribute?
I've hunted around on SO, and Reddit, but haven't found anything pertaining to this problem in particular.
EDIT: This was marked as a possible duplicate of React-router: How to manually invoke Link? but I've tried those answers, and they aren't working.