Comments (4)
This is an interesting one.
I'm wondering what the behavior should be.
Here is a solution in the meantime:
(def render (fn [state node]
(set! (.-innerHTML node) (str "Click me count: " (:count @state)))
(set! (.-onclick node) #(swap! state update-in [:count] inc)))))
(defn render-on-change [render-fn]
(fn [state node]
(add-watch state :rendering (fn [_ _ _ _] (render-fn state node)) ;; idempotent
(render-fn state node)))
(defcard dom-node-updating
"Seems dom-node doesn't update?"
(dom-node (render-on-change render)
{:count 0}
{:inspect-data true})
The parens may be wrong, this is just a quick sketch.
from devcards.
Thanks much, that should do the trick for now.
from devcards.
I ran into this too and came up with a similar solution, but I also notice that the history controls don't appear when the state first changes. They show up after I save the file and Figwheel reloads or make a second state change.
from devcards.
good point, that makes sense
On Fri, Oct 23, 2015 at 7:28 AM, Eric Shull [email protected]
wrote:
I ran into this too and came up with a similar solution, but I also notice
that the history controls don't appear when the state changes. They only
show up after I save the file and Figwheel reloads.—
Reply to this email directly or view it on GitHub
#48 (comment).
from devcards.
Related Issues (20)
- How to render devcards into a HTML element other than #com-rigsomelight-devcards-main? HOT 6
- defcard-rg without a name causes compilation error HOT 2
- Document way of forcing a re-render HOT 1
- Feature: render small preview on the devcards overview page
- Devcards 0.2.6 doesn't work with shadow-cljs HOT 5
- Compile warning: var devcards.core/test-doc is not public HOT 3
- Updating react and react-dom versions for react hooks compatibility
- feature request: Integration with React Native Web
- multiple parameters to devcard
- strip off last namespace
- devcards not updating when changed. HOT 1
- Warning: componentWillMount has been renamed
- [Feature request]: `<details>` support
- Require react directly HOT 4
- Doesn't work with cider-jack-in
- Devcards not reloading when using code splitting
- The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs". HOT 10
- Error: create-react-class could not find the React object.
- Is there a way to massage the state in history mode?
- `lein new devcards` not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devcards.