Fork me on GitHub
#rum
<
2021-07-21
>
sova-soars-the-sora06:07:25

Hey hey rummers. Question for ya.

(rum/defc feedback-widget < rum/reactive []
  [:div#input-phorm
   [:input {:id "ifeedback" 
            :value (rum/react feedback-input)
            :on-change (fn [e] 
              (reset! feedback-input (.. e -target -value))
              (.log js/console @feedback-input))}
    ]])
I want to make a feedback widget to live on every page... If I use the line (.log js/console @feedback-input) there are no problems If I try and replace that line with (.log js/console (rum/react feedback-input)) there are problems, namely an error that says
Uncaught Error: Assert failed: rum.core/react is only supported in conjunction with rum.core/reactive
*reactions*
    at Object.rum$core$react [as react] (core.cljs:396)
    at onChange (app.cljs:64)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3946)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:3995)
    at invokeGuardedCallback (react-dom.development.js:4057)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4071)
    at executeDispatch (react-dom.development.js:8244)
    at processDispatchQueue (react-dom.development.js:8276)
    at eval (react-dom.development.js:8300)
    at eval (react-dom.development.js:22397)
So.... what am I doing wrong

Jan K11:07:46

@sova You can't "react" from inside a function. Using deref/@ is fine here (or just use the return value from reset!).