i try to use is in es6 component and my code looks like this:
class TestComponent extends Component{
constructor(props) {
super(props);
this.displayName = 'TestComponent';
this.mixins = [LocalStorageMixin];
this.state = {
counter:0,
};
this.onClick = this.onClick.bind(this);
}
onClick() {
this.setState({
counter: this.state.counter + 1}
);
}
render() {
return (
<span onClick={this.onClick}>{this.state.counter}</span>
);
}
};
but the state dont stay when i refrash the page... - note that if i use is at regular createclass thats work...
I was looking into using this package, but won't because of the above issue. React.createClass() is deprecated, so it really shouldn't be the main/only entry point into a user's code.
Use react-mixin or submit a hoc pr if you like.
On Sep 8, 2017 9:45 AM, "Daniel Rosensweig" <[email protected]>
wrote:
I was looking into using this package, but won't because of the above
issue. React.createClass() is deprecated, so it really shouldn't be the
main/only entry point into a user's code.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/STRML/react-localstorage/issues/16#issuecomment-328122772>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJFP0Pp0Qxjo3syvBPyMRKfol0_I5wPks5sgVMNgaJpZM4OiRnX>
.
Thanks! I'm looking into react-mixin now. I'd be using this at the moment for a potential-job tech challenge, so no time to create pull requests on the package at the moment. Only a few days for the whole project. I'd probably just connect a database for persistence in a longer-term project, but the goal for now is simple and functional.