Skip to content
Discussion options

You must be logged in to vote

The Button component does not support this. We've had this issue come up internally before and here is the general takeaway:

  • In general, links should look like links instead of buttons.

  • There is a workaround where you can navigate within the Button's onPress handler:

React Router 6.x.x:

const navigate = useNavigate();
...
<Button onPress={() => navigate("/newpage")}>
   Click here
</Button>

React Router 5.x.x:

const history = useHistory();
...
<Button onPress={() => history.push("/newpage")}>
   Click here
</Button>
  • This isn't ideal, because you lose link semantics, however you are already representing it as a button to visual users anyway.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by snowystinger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants