useContext test case broken on node-cljsjs
Deraen opened this issue · 1 comments
Deraen commented
node-cljsjs tests are currently broken because useContext
hook test is failing:
Testing reagenttest.testreagent
Error rendering component (in Object)
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
at resolveDispatcher (target/cljsbuild/node-test/out/cljsjs/react/development/react.inc.js:1501:15)
at Object.useContext (target/cljsbuild/node-test/out/cljsjs/react/development/react.inc.js:1509:22)
at Function.<anonymous> (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagenttest/testreagent.js:12617:57)
at Function.cljs$core$IFn$_invoke$arity$2 (/home/juho/Source/reagent/target/cljsbuild/node-test/out/cljs/core.js:13468:10)
at Function.cljs$core$IFn$_invoke$arity$2 (/home/juho/Source/reagent/target/cljsbuild/node-test/out/cljs/core.js:13753:34)
at cljs$core$apply (/home/juho/Source/reagent/target/cljsbuild/node-test/out/cljs/core.js:13706:24)
at reagent$impl$component$functional_wrap_render (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:627:27)
at reagent$impl$component$functional_do_render (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:676:61)
at reagent$impl$component$functional_render (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:692:52)
at f (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:781:49)
FAIL in (new-context-test) (cljs/test.js:424:14)
useContext hook
expected: (= "<div>Context: foo</div>" (try (rstr [:r> Provider #js {:value "foo"} [:f> comp]]) (catch :default e (js/console.log "ERROR" e))))
actual: (not (= "<div>Context: foo</div>" nil))
Error rendering component (in Object)
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
at resolveDispatcher (target/cljsbuild/node-test/out/cljsjs/react/development/react.inc.js:1501:15)
at Object.useContext (target/cljsbuild/node-test/out/cljsjs/react/development/react.inc.js:1509:22)
at Function.<anonymous> (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagenttest/testreagent.js:12617:57)
at Function.cljs$core$IFn$_invoke$arity$2 (/home/juho/Source/reagent/target/cljsbuild/node-test/out/cljs/core.js:13468:10)
at Function.cljs$core$IFn$_invoke$arity$2 (/home/juho/Source/reagent/target/cljsbuild/node-test/out/cljs/core.js:13753:34)
at cljs$core$apply (/home/juho/Source/reagent/target/cljsbuild/node-test/out/cljs/core.js:13706:24)
at reagent$impl$component$functional_wrap_render (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:627:27)
at reagent$impl$component$functional_do_render (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:676:61)
at reagent$impl$component$functional_render (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:692:52)
at f (/home/juho/Source/reagent/target/cljsbuild/node-test/out/reagent/impl/component.js:781:49)
FAIL in (new-context-test) (cljs/test.js:424:14)
useContext hook
expected: (= "<div>Context: foo</div>" (try (rstr [:r> Provider #js {:value "foo"} [:f> comp]]) (catch :default e (js/console.log "ERROR" e))))
actual: (not (= "<div>Context: foo</div>" nil))
I've ensured react & react-dom are the same version, and no Node React is loaded, and all the calls from Reagent are accessing React through the window / goog.global object.
Deraen commented
I've tested this works on Node when writing JS directly, and I've been unable to find the difference in Reagent code that causes the problem:
https://gist.github.com/Deraen/4b2957ed3b8fe95c23f9693415a8b511
For now, I'm going to disable running tests against node-cljsjs , as that environment probably isn't useful anyway.