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

[@twind/preact,wmr] Can't re-render objects by Cannot set property className of #<Object> which has only a getter #20

Open
riywo opened this issue Jul 21, 2021 · 1 comment · May be fixed by #21

Comments

@riywo
Copy link

riywo commented Jul 21, 2021

See https://codesandbox.io/s/rrjq1?file=/public/index.js

In summary, if you use @twind/wmr and import preact/compat, re-render is broken by the error Cannot set property className of #<Object> which has only a getter

Although I haven't investigated why preact/compat causes this issue, the error itself is caused because the component having tw has className getter when re-render.

First time rendering

> s.__lookupGetter__('className')
undefined

Second time rendering

> s.__lookupGetter__('className')
ƒ (){return this.class}
preact:formatted:25 Uncaught (in promise) TypeError: Cannot set property className of #<Object> which has only a getter
    at Object.T.i.vnode (preact:formatted:25)

When I manually deleted the getter by debugger, the second time rendering succeeded. So, I guess we can implement that logic in @twind/preact regardless of the issue caused by preact/compat.

@riywo
Copy link
Author

riywo commented Jul 21, 2021

This line from preact/compat might be the code changing behaviour: https://github.com/preactjs/preact/blob/c7f57db13af43b8cc3353a138639ad9dd9523e16/compat/src/render.js#L189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant