Я следую за Fulcro 3 Dev Guide , раздел Использование Javascript React Components, с проектом Fulcro Template , пытаюсь импортировать Material-UI Реагируют на компоненты.
Я добавил пакет с npm install --save @material-ui/core
и изменил файл demo_ws.cljs
(ns app.demo-ws
(:require [com.fulcrologic.fulcro.components :as fp]
[nubank.workspaces.core :as ws]
[nubank.workspaces.card-types.fulcro3 :as ct.fulcro]
[com.fulcrologic.fulcro.mutations :as fm]
[com.fulcrologic.fulcro.dom :as dom]
["@material-ui/core/Button" :default material-button]
[com.fulcrologic.fulcro.algorithms.react-interop :as interop]
))
(def ui-button (interop/react-factory material-button))
(fp/defsc FulcroDemo
[this {:keys [counter]}]
{:initial-state (fn [_] {:counter 0})
:ident (fn [] [::id "singleton"])
:query [:counter]}
(dom/div
(str "Fulcro counter demo [" counter "] ")
(ui-button
{:variant "contained"
:color "primary"}
"Another Button")
(dom/button {:onClick #(fm/set-value! this :counter (inc counter))} "+")))
(ws/defcard fulcro-demo-card
(ct.fulcro/fulcro-card
{::ct.fulcro/root FulcroDemo
::ct.fulcro/wrap-root? true}))
, и в консоли возникла ошибка:
Uncaught TypeError: Cannot read property 'root' of undefined
at eval (Button.js:323)
at renderWithHooks (react-dom.development.js:16242)
at updateForwardRef (react-dom.development.js:18125)
at beginWork$1 (react-dom.development.js:20187)
at HTMLUnknownElement.callCallback (react-dom.development.js:337)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:386)
at invokeGuardedCallback (react-dom.development.js:441)
at beginWork$$1 (react-dom.development.js:25739)
at performUnitOfWork (react-dom.development.js:24666)
at workLoopSync (react-dom.development.js:24639)