;<\\/span>\n<\\/code><\\/pre>\nWhen re-entering the tree, the state is shown according to the changes made.<\\/p>\n
You can even dynamically enable/disable persistency, bringing back the default behavior:<\\/p>\n
import<\\/span> Nullstack from<\\/span> 'nullstack'<\\/span>;<\\/span>\nimport<\\/span> Counter from<\\/span> './Counter'<\\/span>;<\\/span>\n\nclass<\\/span> Application<\\/span> extends<\\/span> Nullstack<\\/span> {<\\/span>\n // ...<\\/span>\n persistentCounter =<\\/span> true<\\/span>\n tooglePersistency<\\/span>(<\\/span>)<\\/span> {<\\/span>\n this<\\/span>.<\\/span>persistentCounter =<\\/span> !<\\/span>this<\\/span>.<\\/span>persistentCounter;<\\/span>\n }<\\/span>\n\n render<\\/span>(<\\/span>)<\\/span> {<\\/span>\n return<\\/span> (<\\/span>\n <<\\/span>div<\\/span>><\\/span><\\/span>\n <<\\/span>Counter<\\/span><\\/span> persistent<\\/span>=<\\/span>{<\\/span>this<\\/span>.<\\/span>persistentCounter}<\\/span><\\/span>/><\\/span><\\/span>\n <<\\/span>button<\\/span> onclick<\\/span>=<\\/span>{<\\/span>this<\\/span>.<\\/span>tooglePersistency}<\\/span><\\/span>><\\/span><\\/span>\n Toogle persistency in<\\/span> Counter\n </<\\/span>button<\\/span>><\\/span><\\/span>\n </<\\/span>div<\\/span>><\\/span><\\/span>\n )<\\/span>\n }<\\/span>\n}<\\/span>\n\nexport<\\/span> default<\\/span> Application;<\\/span>\n<\\/code><\\/pre>\n","persistent":true,"locale":"en-US","i18n":{"lead":"Have any questions or suggestions?","cta":"Join our Discord","next":"Next Step","learn":"Learn more about"},"description":"Persistent Components are components that persists on memory","topics":[{"title":"About Nullstack","links":[{"title":"What is Nullstack?","href":"/what-is-nullstack"},{"title":"Getting started","href":"/getting-started"}]},{"title":"Core Features","links":[{"title":"Stateless Components","href":"/stateless-components"},{"title":"Stateful components","href":"/stateful-components"},{"title":"Full stack lifecycle","href":"/full-stack-lifecycle"},{"title":"Server functions","href":"/server-functions"},{"title":"Context","href":"/context"},{"title":"Two-way bindings","href":"/two-way-bindings"},{"title":"JSX elements","href":"/jsx-elements"},{"title":"Refs","href":"/refs"},{"title":"Styles","href":"/styles"},{"title":"Persistent Components","href":"/persistent-components"}]},{"title":"Context Keys","links":[{"title":"Routes and params","href":"/routes-and-params"},{"title":"Context data","href":"/context-data"},{"title":"Context instances","href":"/context-instances"},{"title":"Context environment","href":"/context-environment"},{"title":"Context page","href":"/context-page"},{"title":"Context project","href":"/context-project"},{"title":"Context settings","href":"/context-settings"},{"title":"Context secrets","href":"/context-secrets"},{"title":"Server request and response","href":"/server-request-and-response"},{"title":"Service Worker","href":"/service-worker"}]},{"title":"Advanced concepts","links":[{"title":"Proxy","href":"/proxy"},{"title":"Application Startup","href":"/application-startup"},{"title":"Script runner","href":"/script-runner"},{"title":"How to customize Webpack","href":"/how-to-customize-webpack"},{"title":"Transpilation and Security","href":"/transpilation-and-security"},{"title":"TypeScript","href":"/typescript"}]},{"title":"Build Modes","links":[{"title":"Server-side rendering","href":"/server-side-rendering"},{"title":"Static site generation","href":"/static-site-generation"},{"title":"Single page applications","href":"/single-page-applications"}]},{"title":"Other","links":[{"title":"Nullstack Logo","href":"/nullstack-logo"},{"title":"How to deploy","href":"/how-to-deploy-a-nullstack-application"}]}]},"GoogleAnalytics/0-0-0-19":{"persistent":false},"Loader/0-0-0-21":{"persistent":false},"Footer/0-0-0-22":{"persistent":false,"locale":"en-US","i18n":{"links":[{"title":"YouTube","href":"https://www.youtube.com/channel/UCUNPaxoppH3lu6JTrUX78Ww"},{"title":"Twitter","href":"https://twitter.com/nullstackapp"},{"title":"GitHub","href":"https://github.com/nullstack"}],"star":{"story":"Want to show your love and help us spread the word?","action":"Leave a star on GitHub"}}}},"context":{"mode":"light","oppositeMode":"dark"}}