J
J
jondoeonoe2018-08-24 19:28:59
React
jondoeonoe, 2018-08-24 19:28:59

Redux toggle how to implement?

Good evening. Started studying with Redax. And there is a simple task - toggle.
There is a parent that, when true, fulfills one condition, and when false, another. And there is a component (at a distance from the parent, for example, 2-3 components), which should determine these bool - values. I.e. If we clicked on the button in this remote component, then state = !state, in general, a state switch. And I do not quite understand how to implement this.
I looked at the example https://codepen.io/cassiecodes/pen/VKZqBd
But I did not quite understand how to do this so that the parent "listens" to what is happening in the remote child. Chaining through components?
Tell me please :(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Spirin, 2018-08-24
@jondoeonoe

To solve your problem, in a good way, redux is not needed. If you purposefully want to implement using redux, then rewrite the example from the link line by line and try to parse it. If it doesn't work - study the documentation, you seem to have begun to study it. If you have specific questions besides "I don't understand anything", ask.

K
Khatam Soyunov, 2020-01-05
@hattam

Might be useful to someone.
You need to return the new changed state in its entirety. More details https://stackoverflow.com/a/40701007/9927320

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question