tomkp / react-split-pane

React split-pane component
https://tomkp.github.io/react-split-pane
MIT License
3.22k stars 408 forks source link

save split size change after refresh #805

Open MorDery opened 2 years ago

MorDery commented 2 years ago

I use split pane to split the screen to two part and I initial the size to 20%. I need that if I change the size and refresh the page the size stay on the new size and don't return to 20% again. can you help me to do that?

RahafJ96 commented 2 years ago
  1. You can use the localStorage (HTML5 browsers only) - you could save it as a property of the page's local storage allowance

  2. Save it in a cookie

    
    // Set a cookie or 2
    document.cookie = 'somevar=somevalue';
    document.cookie = 'another=123';

function getCookie(name) { // Cookies seperated by ; Key->value seperated by = for(var i = 0; pair = document.cookie.split("; ")[i].split("="); i++) if(pair[0] == name) return unescape(pair[1]);

// A cookie with the requested name does not exist
return null;

}

// To get the value alert(getCookie('somevar'));



3. Append the variable to the URL hash so it's retrievable via `location.hash` after the refresh

[source](https://www.w3schools.com/js/js_cookies.asp) 
MorDery commented 2 years ago

can you tell me what is the hoke I need to catch to save the change?