reagent

itaied 2023-09-13T08:12:19.592039Z

Hey all, I'm trying to run a react component that use hooks and I get a setup error in the consumer:

[:> ReactComponent {}]
Error:
Uncaught TypeError: Cannot read properties of undefined (reading 'setup')
    at eval (ui.esm.js:873:36)
    at handleInterpolation (serialize.browser.esm.js:146:24)
    at serializeStyles (serialize.browser.esm.js:266:15)
    at eval (styled-base.browser.esm.js:121:93)
    at updateContextConsumer (react-dom.development.js:18304:19)
    at beginWork (react-dom.development.js:18661:14)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237:16)
    at invokeGuardedCallback (react-dom.development.js:292:31)
    at beginWork$1 (react-dom.development.js:23203:7)
2nd Error:
The above error occurred in the <Context.Consumer> component:
...
Should I configure something else for using a react component (as a black box) that makes use of hooks?

p-himik 2023-09-13T08:20:53.573839Z

You shouldn't have to. Are you sure there aren't any obligatory arguments that you must pass to that component?

itaied 2023-09-13T08:26:57.526109Z

almost sure, I'll double check, but I think if there's a required argument I'll get a different error

p-himik 2023-09-13T08:27:28.759719Z

Not necessarily. If there's no check for it, you get undefined behavior.

p-himik 2023-09-13T08:32:06.536839Z

What version of emotion-js are you using?

itaied 2023-09-13T08:32:46.446189Z

"@emotion/core": "10.1.1",

itaied 2023-09-13T08:35:29.133189Z

I suspect missing theme provider in my components tree

p-himik 2023-09-13T08:35:53.995639Z

Are you using stuff like babel or webpack? If not, what is the version of @emotion/serialize that you have installed, in package-lock.json?

itaied 2023-09-13T08:37:35.129829Z

Yes I'm using webpack

itaied 2023-09-13T08:38:33.369639Z

but i think i have found the root cause, it's a missing provider.

...theme.button.setup,
and the error is pointing there (the setup part)

👍 1
schadocalex 2023-09-13T16:19:58.970019Z

Hi there! On Chrome (107 and 117, Linux and Mac at least), I can't see the cursor when I'm typing into a input (text/number). You can test on https://reagent-project.github.io/ in the share state example. If you type different characters until the input is full, you won't see the last one nor the cursor. But you can go left/right with the keyboard and then you see it. Do you know why? Looks like it works with official React examples, so maybe Reagent triggers a Chrome bug. (It works on FF, does not on Safari)

2023-09-17T16:24:11.819419Z

By this image, I think you're updating the stare from onkeydown or onkeypressed event instead of onkeyup

schadocalex 2023-09-17T19:38:20.572739Z

The code is under the example (it’s on-change)

2023-09-17T19:42:55.515729Z

When your state swap! is called in the keydown event, the state gets updated before the character is dropped in the input field. Unlike the keyup event where the character has been dropped. So when you press the arrow keys, it updates the state with the last character. I believe this is what you're talking to you

schadocalex 2023-09-17T19:49:18.389469Z

Maybe you’re right, but it’s the official example of how to do in reagent. I’ve created an issue tho https://github.com/reagent-project/reagent/issues/595

2023-09-17T19:52:43.469479Z

I've tested it, it works perfectly. Don't know what's the issue at your end.

2023-09-17T19:53:30.231609Z

It used the onchange event which should work well as expected

schadocalex 2023-09-17T19:54:16.504429Z

On chrome? Which version? I asked a friend and I tried in Linux and Mac and the three times it was buggy.

2023-09-17T19:56:32.621729Z

Even in chrome (mobile), it works fine over here

schadocalex 2023-09-17T20:00:59.251169Z

2023-09-17T20:03:10.724639Z

I still don't get the issue here

schadocalex 2023-09-17T20:04:54.637699Z

I can’t see the last letter. On PC I can’t even see the cursor nor a part of the last letter

schadocalex 2023-09-17T20:05:47.489099Z

(And no it’s not due to CSS)

2023-09-17T20:06:22.899499Z

Your browser UI theme?

schadocalex 2023-09-17T20:07:55.758289Z

It’s not CSS it works well in pure html or even React

2023-09-17T20:09:44.540429Z

It's ok

schadocalex 2023-09-13T16:21:01.449449Z

Expected behaviour:

liebs 2023-09-13T19:07:40.396569Z

I seem to recall there's some gotchas when rendering React Native components and that it is documented somewhere? But I can't find it. Can someone refresh my memory if that's real?