Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useContext test case broken on node-cljsjs #530

Open
Deraen opened this issue Feb 12, 2021 · 1 comment
Open

useContext test case broken on node-cljsjs #530

Deraen opened this issue Feb 12, 2021 · 1 comment

Comments

@Deraen
Copy link
Member

Deraen commented Feb 12, 2021

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 Deraen added the bug label Feb 12, 2021
@Deraen
Copy link
Member Author

Deraen commented Apr 25, 2021

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.

@Deraen Deraen added the wontfix label Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant