that is, refresh the page user data, the page status is still there, how is this done?
that is, refresh the page user data, the page status is still there, how is this done?
if the refresh of the system is used, the data state will not be saved. By refresh, you mean routing jump?
this is simple, just use localStorage
directly, which is often used in my projects.
getInitialState: function() {
var selectedOption = localStorage.getItem( 'SelectedOption' ) || 1;
return {
selectedOption: selectedOption
};
},
setSelectedOption: function( option ) {
localStorage.setItem( 'SelectedOption', option );
this.setState( { selectedOption: option } );
}