Call to custom states inside a Splide event #549
Answered
by
NaotoshiFujita
fabiangothman
asked this question in
Q&A
-
Hey there, I'm trying to get a ReactJS state inside "Move" event but I'm always getting the initial data from the state, not the updated one. Could you give an example in ReactJS about how could we handle states inside Splide events. Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
NaotoshiFujita
Dec 1, 2021
Replies: 1 comment
-
It's very simple. export default class App extends React.Component {
state = {
count: 0
};
render() {
return (
<Splide
onMove={ () => console.log( this.state.count ) }
onMoved={ () => this.setState( { count: this.state.count + 1 } ) }
>
</Splide>
);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
NaotoshiFujita
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's very simple.