While a UIx component tree can be reloaded in a traditional way, by re-rendering from the root after reload, this resets component local state and re-runs hooks. It happens because the reloaded namespace will create new component functions, which in turn invalidate the UI tree when re-rendering after reload and cause the updated components to be re-mounted.
react-refresh makes it possible to reload components in a way that preserves local state and the state of hooks.
Make sure you have React DevTools installed for your browser
Install the package npm install react-refresh --save-dev
Add uix.preload
to :preloads
so that it's only loaded in dev
;; shadow-cljs.edn
{:builds
{:build-id
{:devtools {:preloads [uix.preload]}}}}
Make sure that your UI is not re-rendered from the root in a traditional way when using fast-refresh, otherwise fast-refresh won't work and the state will be reset.
Can you improve this documentation? These fine people already did:
Roman Liutikov, Shaun Mahood & roman01laEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close