I
I
Ibishka2020-09-19 17:36:44
React
Ibishka, 2020-09-19 17:36:44

Is it bad to use onClick with Link React js?

I need to execute the handle() function and redirect the user to the home page. To shorten things, I didn’t use history push in the handle function and didn’t hang onClick on the button, but directly hung the handle function on the Link with the to attribute value home onClick . Is this normal or is it more correct with button and history push?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Matyushkin, 2020-09-19
@Ibishka

If Link can take an onClick value (and it can take such an argument), then not bad. Well, ideally, if the handle function is described in the component, and does not come from props, then it is desirable to describe it in the form of useCallback.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question