mirror of https://github.com/status-im/reagent.git
Fix #401 if jsprops is nil before adding key, key is lost
If jsprops was nil before key oset call, oset created a new object for the jsprops, but because the return value from oset was not used, the object was lost.
This commit is contained in:
parent
d9057eaecf
commit
62f87292a2
|
@ -323,9 +323,10 @@
|
|||
(let [props (nth argv 1 nil)
|
||||
hasprops (or (nil? props) (map? props))
|
||||
jsprops (convert-prop-value (if hasprops props))
|
||||
jsprops (if-some [key (key-from-vec argv)]
|
||||
(oset jsprops "key" key)
|
||||
jsprops)
|
||||
first-child (+ 1 (if hasprops 1 0))]
|
||||
(when-some [key (key-from-vec argv)]
|
||||
(oset jsprops "key" key))
|
||||
(make-element argv react/Fragment jsprops first-child)))
|
||||
|
||||
(defn adapt-react-class
|
||||
|
|
|
@ -1189,8 +1189,12 @@
|
|||
[:div "hello"]
|
||||
[:div "world"]]
|
||||
^{:key 2}
|
||||
[children])])]
|
||||
(is (= "<div><div>hello</div><div>world</div><div>foo</div></div>"
|
||||
[children]
|
||||
^{:key 3}
|
||||
[:<>
|
||||
[:div "1"]
|
||||
[:div "2"]])])]
|
||||
(is (= "<div><div>hello</div><div>world</div><div>foo</div><div>1</div><div>2</div></div>"
|
||||
(as-string [comp]))))))
|
||||
|
||||
(defonce my-context (react/createContext "default"))
|
||||
|
|
Loading…
Reference in New Issue