C
C
colorkid2017-01-02 23:50:28
JavaScript
colorkid, 2017-01-02 23:50:28

How to change the state of the "parent" component in react?

Hello everyone
I just started to learn react, I haven't fully understood what there is a component, etc. . The bottom line is this, I want to make a carousel slider.
Here is the code codepen.io/anon/pen/bgbXoE The
handler hangs on the button to the right onClick={this.toRightSlider}>
I want to change the state of the "parent" component Images according to it. But it does not change in any way, and then I discovered that I can’t reach external functions outside of var Buttons at all.
How would all the same, by clicking on the buttons to the right / left, the positionSlider state of Images would change?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2017-01-03
@colorkid

You need to create a method in Images that changes its state, bind this method to Images and pass this method to Buttons.
On es6+ it looks something like this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question