react-webcomponentify icon indicating copy to clipboard operation
react-webcomponentify copied to clipboard

should render ReactNode in connectedCallback not constructor?

Open WeiRu1016 opened this issue 5 years ago • 2 comments

image

in constructor create and render ReactNode, let we can't setProps before render ReactNode. because HTML attr is not support Camel-Case。

so create and render ReactNode in connectedCallback better

WeiRu1016 avatar Nov 04 '21 09:11 WeiRu1016

Hi @WeiRu1016. Thanks for using this lib and your contribution to this project. Would you be able to create an example with described issue in https://codesandbox.io/ or similar?

kopach avatar Dec 06 '21 12:12 kopach

sorry, This is demo: https://codesandbox.io/s/react-web-component-ugmyj9?file=/src/index.tsx

because textValue is camel-case props, html5 attributes is not support camel-case attributes. so use setProps.

but before setProps, react component has created and mounted. props textValue is required props, but now is undefined.

if ExampleComplete used textValue to acc, will cause render error!!!

I suggest renderRender2Node is move to connectedCallback.

WeiRu1016 avatar Mar 04 '22 07:03 WeiRu1016