Cannot manipulate cursor outside of render phase

clojurescript, om

Solution

I think the problem is where you access `data` inside om/transact! where you should operate on `v`:

`(:current v)` instead of `(:current data)`

or you may try `(:current @data)` for most recent value of data

Problem

Trying react for the first time, and I want to make a simple todo list app. But every time I press enter to trigger `onSubmit` it says `Uncaught Error: Cannot manipulate cursor outside of render phase, only om.core/transact!, om.core/update!, and cljs.core/deref operations allowed`. While I think this is a very good error message, I don't know what to do. ``` (ns app.core (:require [om.core :as om :include-macros true] [sablono.core :as html :refer-macros [html]])) (def app-state (atom {:todos [{:todo "first"} {:todo "second"}] :current ""})) (defn to-do [data] (om/component (html [:li (:todo data)]))) (defn to-dos [data] (om/component (html [:div [:form {:on-submit (fn [e] (.preventDefault e) (om/transact! data :todos (fn [v] (js/console.log (:current data)) (conj v (:current data)))))} [:input {:type "text" :placeholder "Enter some text." :on-change (fn [e] (om/update! data :current (.. e -target -value)))}]] [:ul (om/build-all to-do (:todos data))]]))) (om/root to-dos app-state {:target js/document.body}) ```

Original source