F
F
Fejja2020-05-11 16:59:53
React
Fejja, 2020-05-11 16:59:53

How to open different divs when clicking on different blocks?

How to open at a clique - I understand. But how can a certain div be "attached" to a block? So that when you click, different ones open. On pure JS, one could use data-target for example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2020-05-12
@HistoryART

e.target familiar? Perhaps I did not understand you correctly.

E
Egor Zhivagin, 2020-05-12
@Krasnodar_etc

You must have some component that is "above" all the components where you need to show/hide something. With it, you make a true / false state, which will be responsible for showing / hiding the block. (Instead of all this, you can use redux)
You pass this state through props to all places where you need to show / hide something depending on it
Of course, I described it rather abstractly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question