N
N
Nikolai2019-02-18 14:53:48
React
Nikolai, 2019-02-18 14:53:48

How to get rid of redundant renders?

I have two menus. Each highlights its active item. It is defined using withRouter . BUT when switching in one menu, re-rendering occurs in another, which, in my opinion, is not good. This happens due to the fact that the props lacation.pathname is changed , which is used both there and there. What is the best way to implement active points then?
As an option, in each menu, create an array with all your own routes, and in shouldComponentUpdate check for the presence of the current route. It smells like a crutch .... Or not?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nluparev, 2019-02-18
@nluparev

and each menu cannot have its own local state that will store the active item? Or is it somehow tied to the general navigation of the application?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question