Add optional onChange callback
dmytrotkk opened this issue · comments
Dmytro commented
It would be nice to have something like that for words change action:
textChange(textLoopState){
// do something...
}
<TextLoop onChange={textChange}>
{wordsObj}
</TextLoop>
My proposal:
// TextLoop.jsx
tick = () => {
this.setState((state, props) => {
+ if(this.props.onChange){
+ this.props.onChange(state);
+ }
...
});
};
Bernardo Raposo commented
Hi @Dmitry-Tk, sorry for the delay but it seems like a sensible proposal. I've been making some improvements to the library, but just didn't have the time to put everything together and make a new release.
I'll definitely add this to the API, but if you want to contribute please feel free to open a PR!
Bernardo Raposo commented
onChange
callback is now supported on v2.0.0