🤝Atomico and React
React and webcomponents
React has begun to support the use of webcomponents in an experimental way, this will allow to use custom tag with association of events and more, example:
Advantages: The react team will take care of the coverage of this characteristic.
Disadvantages: (Optional) The maintainer of the component must declare the types of the custom tag.
Although the use of the custom tag is a way of instantiating the component, many times it does not define the import path at the time of its use, complicating the resolution of the component's origin, to avoid this we recommend the use of the Atomico wrapper for React.
Atomico wrapper for React
Atomico the package @atomic/react allows:
Create a Wrapper component for the custom Element
Avoid react conflicts with webcomponents, such as association of events, attributes, properties and children.
Reflect the types declared in Atomic to React, valid for JSX or TSX
Coverage is automatic if you decide to share your package using @atomico/exports under the following export conditions.
Atomico inside Next.js
All webcomponents work in Next if it escapes from SSR
Example of custom tag usage
Example of use of the wrapper.
Remember if you use the auto
module, it should always be imported first than the customElement to use, otherwise auto
will generate an id as a custom tag to instantiate the component within react
Last updated