Add static contextType test

This commit is contained in:
Juho Teperi 2019-12-17 02:21:05 +02:00
parent 4c5dd6fd7b
commit 07bfa901ac
2 changed files with 11 additions and 2 deletions

View File

@ -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)

View File

@ -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})