mirror of
https://github.com/status-im/reagent.git
synced 2025-02-05 00:23:48 +00:00
Add static contextType test
This commit is contained in:
parent
4c5dd6fd7b
commit
07bfa901ac
@ -70,7 +70,7 @@ Alternatively you can use the [static contextType property](https://reactjs.org/
|
||||
```
|
||||
|
||||
Tests contain example of using old React lifecycle Context API (`context-wrapper` function):
|
||||
[tests](https://github.com/reagent-project/reagent/blob/master/test/reagenttest/testreagent.cljs#L1141-L1165)
|
||||
[tests](https://github.com/reagent-project/reagent/blob/master/test/reagenttest/testreagent.cljs#L1159-L1168)
|
||||
|
||||
## [Error boundaries](https://reactjs.org/docs/error-boundaries.html)
|
||||
|
||||
|
@ -1257,7 +1257,16 @@
|
||||
(rstr [:> Provider {:value "bar"}
|
||||
[:> Consumer {}
|
||||
(fn [v]
|
||||
(r/as-element [:div "Context: " v]))]])))))
|
||||
(r/as-element [:div "Context: " v]))]]))))
|
||||
|
||||
(testing "static contextType"
|
||||
(let [comp (r/create-class
|
||||
{:context-type my-context
|
||||
:reagent-render (fn []
|
||||
(this-as this
|
||||
(r/as-element [:div "Context: " (.-context this)])))})]
|
||||
(is (= "<div>Context: default</div>"
|
||||
(rstr [comp]))))))
|
||||
|
||||
(deftest on-failed-prop-comparison-in-should-update-swallow-exception-and-do-not-update-component
|
||||
(let [prop (r/atom {:todos 1})
|
||||
|
Loading…
x
Reference in New Issue
Block a user