Reagent プロジェクトで、CSS を使用して HTML を Hiccup に解析しようとしています。ヒッコリーを使用しています。HTML をインライン CSS で解析すると、React が例外をスローします。
(map
as-hiccup (parse-fragment "<div style='color:red'>test</div>")
)
上記は[:div {:style color:red} "test"]
& Reactjs が Reactjs から例外を返します:
Violation: The style prop expects a mapping from style properties to values, not a string.
[:div {:style {"color" "red"}} "test"]
代わりに返さなければならないと思います。
コードビューは次のとおりです。
(ns main.views.job
(:require [reagent.core :as reagent :refer [atom]]
[hickory.core :refer [as-hiccup parse parse-fragment]]))
(enable-console-print!)
(defn some-view [uid]
[:div
(map as-hiccup (parse-fragment "<div style='color:red'>test</div>"))
])