N
N
Nikita2020-01-30 03:46:35
React
Nikita, 2020-01-30 03:46:35

How to remove blinking buttons?

I am making an application on React and when developing the navBar there was such a problem that the icons blink when changing from active to inactive
This is logical, because I have a boolean property, depending on which I change the path to the icon
<img src={IsAcitve ? activeIncon : icon} />
Tell me how to solve this problem?
SVG Icons

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lilwings, 2020-01-30
@lilwings

Use the icon not in the directory but in the sprite.
1) Create a sprite with all icons
2) When accessing the first icon, the entire sprite will go into the cache and blinking will disappear
PS: I can give an example from the Angular application, the logic will be the same

M
McBernar, 2020-01-30
@McBernar

Another option is to force the download through new Image() in didMount. Then they will be cached immediately when the component is loaded.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question