Most people who use React don’t use Web Components, but you may want to, especially if you are using third-party UI components that are written using Web Components.

class HelloMessage extends React.Component {
  render() {
    return <div>Hello <x-search>{}</x-search>!</div>;
One common confusion is that Web Components use “class” instead of “className”.

function BrickFlipbox() {
  return (
    <brick-flipbox class="demo">

Assuming that is a Typescript compile error. You need to add typescript declarations to your react-app-env.d.ts

declare namespace JSX {
    interface IntrinsicElements {
        'vaadin-text-field': { 'prop': any };
        'vaadin-button d': { 'prop': any };

class XSearch extends HTMLElement {
  connectedCallback() {
    const mountPoint = document.createElement('span');
    this.attachShadow({ mode: 'open' }).appendChild(mountPoint);

    const name = this.getAttribute('name');
    const url = '' + encodeURIComponent(name);
    ReactDOM.render(<a href={url}>{name}</a>, mountPoint);
customElements.define('x-search', XSearch);

Make sure <ListEnterprises /> is loaded as a Route component, history will automatically be provided in props and can be accessed using this.props.history.

<Route path="/enterprises" component={ListEnterprises} />

Alternatively to cookies you could use localStorage. Here's a basic example of that. It sets an item in the storage once the main component is mounted and reacts to that item in the render() method.

componentDidMount() {
  // Get item from localStorage and save it to a constant.
  const hasVisitedBefore = localStorage.getItem('hasVisitedBefore');

  // Check if the user has visited the site (component) before.
  if (!hasVisitedBefore) {
    // If not, set the component state (or dispatch an action if you need)
    // Also set the localStorage so it's globally accessible.
    this.setState({ hasVisitedBefore: false });
    localStorage.setItem('hasVisitedBefore', true);

// Based on the state set in `componentDidMount()`, show or hide the welcome modal.
render() {
  return (
        ? 'Welcome back!'
        : 'Welcome for the first time!'}

I assume you're trying to pass remotes='remotes' to MyTab. Components rendered by a Route are passed only the route props, but you can use an anonymous inner function to slip in extra props. Don't forget to pass on the route props if you need them!

  component={routeProps => <MyTab {...routeProps} remotes='remotes' />}

You might not want to use map in this case since you only want to render one movie. You could instead use the find method and render that single movie if it's found.

class Movie extends Component {
  // ...

  render() {
    const { movies, movieId } = this.state;
    const movie = movies.find(movie => === movieId);

    return (
      <div className="movie-info">
        {movie ? <h1 key={}>{movie.event.title}</h1> : null}

In functional components using hooks:

useEffect(() => {
    const script = document.createElement('script');
    script.src = "";
    script.async = true;
    return () => {
        document.body.removeChild(script); // This will remove the script on unmount
}, []);

Array.prototype.reverse() reverses the elements in place. You'll need to pass a new array into setData().

  onClick={() => {
    var newData = data;

    // Create a new array using the spread operator


React Context Caveats

React Context Examples Consuming Multiple Contexts

React Context Examples Updating Context from a Nested Component

React Context Examples Dynamic Context

React Context API Context.displayName

React Context API Context.Consumer

React Context API Class.contextType

React Context API Context.Provider

Context API React.createContext

React Context Before You Use Context

React Context When to Use Context

React JavaScript Environment Requirements

React Error Boundaries How About Event Handlers?

React Error Boundaries How About try/catch?

React Error Boundaries Introducing Error Boundaries

React Higher-Order Components Caveats Static Methods Must Be Copied Over

React Higher-Order Components Caveats Don’t Use HOCs Inside the render Method

React Higher-Order Components Convention: Wrap the Display Name for Easy Debugging

React Higher-Order Components Convention: Maximizing Composability

React Higher-Order Components Convention: Pass Unrelated Props Through to the Wrapped Component

React Higher-Order Components Don’t Mutate the Original Component. Use Composition.

React Higher-Order Components Use HOCs For Cross-Cutting Concerns

React Higher-Order Components

React Portals Event Bubbling Through Portals

React Portals Usage

React Portals

React Introducing JSX JSX Represents Objects

React Introducing JSX JSX Prevents Injection Attacks

React Introducing JSX Specifying Children with JSX

React Introducing JSX Specifying Attributes with JSX

React Introducing JSX JSX is an Expression Too

React Introducing JSX Embedding Expressions in JSX

React Introducing JSX

React State and Lifecycle The Data Flows Down

React State and Lifecycle Using State Correctly State Updates are Merged

React State and Lifecycle Using State Correctly State Updates May Be Asynchronous

React State and Lifecycle Using State Correctly Do Not Modify State Directly

React State and Lifecycle Adding Lifecycle Methods to a Class

React State and Lifecycle Adding Local State to a Class

React State and Lifecycle Converting a Function to a Class

React State and Lifecycle

React Test Renderer Ideas

React Test Renderer Reference testInstance.children

React Test Renderer Reference testInstance.parent

React Test Renderer Reference testInstance.props

React Test Renderer Reference testInstance.type

React Test Renderer Reference testInstance.instance

React Test Renderer Reference testInstance.findAllByProps()

React Test Renderer Reference testInstance.findAllByType()

React Test Renderer Reference testInstance.findAll()

React Test Renderer Reference testInstance.findByProps()

React Test Renderer Reference testInstance.findByType()

React Test Renderer Reference testInstance.find()

React Test Renderer Reference testRenderer.root

React Test Renderer Reference testRenderer.getInstance()

React Test Renderer Reference testRenderer.unmount()

React Test Renderer Reference testRenderer.update()