@atomico/react
Wrapper to use webcomponents in React
¿What is @atomico/react?
It is a Wrapper to eliminate React's own problems when rendering webcomponents, with @atomico/react you can:
Using your webcomponent's type declarations in React/Preact
Synchronize the events of your webcomponents with React
Composition from React using children and slots
Use SSR of your webcomponents in React/Preact based environments for example Next.js
When to use @atomico/react?
We recommend using Atomico/react when looking to support React or Preact from your webcomponents built with Atomico.
We also support vue with @atomico/vue
@atomico/react vs other solutions?
With Atomico/react it's really easy to use, example:
import { auto } from "@atomico/react";
import { MyComponent as _MyComponent } from "./my-component.js";
export const MyComponent = auto( _MyComponent );
import * as React from 'react';
import { createComponent } from '@lit-labs/react';
import { MyComponent as _MyComponent } from './my-component.js';
export const MyComponent = createComponent({
tagName: 'my-component', //⚠️ requires the tagName
elementClass: _MyComponent,
react: React, //⚠️ requires react module
events: { //⚠️ requires events
onactivate: 'activate',
onchange: 'change',
},
});
Example
import { auto } from "@atomico/react";
import { HTMLMyComponent } from "./my-component.js";
export const MyComponent = auto( HTMLMyComponent );
@atomico/exports
We invite you to meet @atomico/exports to automate the generation of wrappers for your webcomponents