React 18 and earlier
TypeScript Configuration
Add the Web Component types to your TypeScript configuration:
{ "compilerOptions": { "types": [ // Required: Enables JSX type support for React 18 and earlier "@staticbolt/wcp/types/react18",
// Optional: Adds native DOM types (e.g. `querySelector`, `document`) "@staticbolt/wcp/types/dom",
// Optional: Exposes component types globally (no imports needed) "@staticbolt/wcp/types/global", ], },}This provides TypeScript support for the web components in your React application.
Importing Web Components
Web components are registered globally in the browser. Import them once in your application’s entry point:
import "@staticbolt/wcp/[component-name]";Important: Do not import web components in multiple files. them only once at application startup.
Using Components with React 18 and earlier
React 18 and earlier does not support setting JavaScript properties or attaching events using JSX, its only support setting HTML attributes. To attach events or settings JavaScript properties use the native DOM API via react ref.
Using Slots
Use children to render the content of the web component:
<component-name> <span slot="title">Title</span> <span>Content</span></component-name>