From f1286baa974746bba0ab6918f1ab47dca66929f9 Mon Sep 17 00:00:00 2001 From: JulianLeviston Date: Sat, 8 Aug 2015 01:33:19 +1000 Subject: [PATCH] Change r/atom defs to defonce For better compatiblity with figwheel, change the two references that are def'd with r/atom values to be defonce so they persist through code updates. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 58aa464..e6940b9 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ assuming we have imported Reagent like this: State is handled using Reagent's version of `atom`, like this: ```clj -(def click-count (r/atom 0)) +(defonce click-count (r/atom 0)) (defn state-ful-with-atom [] [:div {:on-click #(swap! click-count inc)} @@ -116,7 +116,7 @@ This way you can avoid using React's lifecycle callbacks like `getInitialState` But you can still use them if you want to, either using `reagent.core/create-class` or by attaching meta-data to a component function: ```clj -(def my-html (r/atom "")) +(defonce my-html (r/atom "")) (defn plain-component [] [:p "My html is " @my-html])