Facebook uses a single-page application made by react, so how does it save page state data?

that is, refresh the page user data, the page status is still there, how is this done?

Jun.29,2022

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 } );
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3223c-2bde0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3223c-2bde0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?