Using Web Components with React just got better!

Опубликовано: 03 Март 2026
на канале: A shot of code
5,569
73

Until now using a Web Component from within a react application was a bit hit and miss. There were issues with handling event and passing certain properties that are now resolved in the latest experimental release of React. All going well we'll see these updates in the v18 release once it goes live but for now we can show how this improves the use of Web Components in React using the experimental v18 release.

In this demo we create a Lit Element web component and place it into a simple react application and then fire and event from the web component and look to handle it in the react application. This fails using the existing v17 release of React but once we upgrade to v18experimental the event is happily handled in the correct manner.

This is another step towards web components being able to be used in all scenarios, SSR the next hurdle I think...

0:55 Setup
1:15 React Setup
4:05 Lit Setup
10:45 Existing issue with handling events
11:45 Setup React vNext v18 Experimental
14:20 Working React events with Web Component