Created
November 29, 2016 18:59
-
-
Save jstaffans/ba99d38075c76b289bfc15576ed7b094 to your computer and use it in GitHub Desktop.
re-frame reloading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4:31 PM] | |
jstaffans what do I have to do to make the re-frame simple example preserve state when figwheel reloads? ie the content of the input gets reset to the default value when figwheel reloads currently. https://github.com/Day8/re-frame/tree/master/examples/simple) | |
[6:30 PM] | |
pesterhazy @jstaffans that should work actually | |
[6:32 PM] | |
what I'd do is to start debugging where reloading goes off the rails | |
[6:32 PM] | |
I'd start by adding logging to the render functions, printing out global state | |
[6:32 PM] | |
isolate if global state gets updated incorrectly | |
[6:33 PM] | |
the simple example seems a bit too simple also in that it doesn't re-render the root component (there's no on-js-reload fn as far as I can see) | |
[6:34 PM] | |
it might be worth copy'n pasting the example into tenzing (or chestnut if you prefer lein?) | |
[6:35 PM] | |
I suspect the issue is not to do with re-frame but with reagent or tooling by the way | |
[6:41 PM] | |
jstaffans Thanks @pesterhazy, I'll try that out | |
[6:42 PM] | |
I was expecting something like an on-js-reload function being needed | |
[6:50 PM] | |
pesterhazy a couple of other reloading gotchas: | |
- using clojure.core/atom instead of reagent.core/atom | |
- forgetting to use `#'component` to enable reloading | |
- top-level root component sometimes don't get updated properly; wrap in another component to be sure | |
- "rookie mistake"? https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components#form-1-a-simple-function | |
- input fields: `default-value` vs `value` | |
- logic check: does the component to update deref the ratom? | |
- defmethod based components can be wonky in reagent | |
- on-js-reload should re-mount root component |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment