### Complete example of React component creation and nesting
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/index.md
A comprehensive example combining the definition of a simple button component and its integration into a main application component, illustrating how multiple components form a UI.
```js
function MyButton() {
return (
);
}
export default function MyApp() {
return (
Welcome to my app
);
}
```
--------------------------------
### Complete Example: Rendering List of Fragments with Key
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/Fragment.md
A full, runnable example demonstrating how to render a list of React Fragments, each with a unique `key`, within a component. Includes helper components and sample data to show the complete setup.
```javascript
import { Fragment } from 'react';
const posts = [
{ id: 1, title: 'An update', body: "It's been a while since I posted..." },
{ id: 2, title: 'My new blog', body: 'I am starting a new blog!' }
];
export default function Blog() {
return posts.map(post =>
);
}
function PostTitle({ title }) {
return
{title}
}
function PostBody({ body }) {
return (
{body}
);
}
```
--------------------------------
### Try React in an online sandbox
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/installation.md
This snippet demonstrates a basic React functional component and its usage within an App component. It shows how to define a component, pass props, and render it, allowing users to quickly experiment with React without any local setup.
```js
function Greeting({ name }) {
return
Hello, {name}
;
}
export default function App() {
return
}
```
--------------------------------
### React Render Tree Example: Get Inspired App
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/understanding-your-ui-as-a-tree.md
This comprehensive example illustrates a React application that generates inspirational quotes, demonstrating component composition and the formation of a render tree. It includes the main application component, reusable text components, a quote generator, a copyright component, a data module, and associated styling.
```js
import FancyText from './FancyText';
import InspirationGenerator from './InspirationGenerator';
import Copyright from './Copyright';
export default function App() {
return (
<>
>
);
}
```
```js
export default function FancyText({title, text}) {
return title
?
{text}
:
{text}
}
```
```js
import * as React from 'react';
import quotes from './quotes';
import FancyText from './FancyText';
export default function InspirationGenerator({children}) {
const [index, setIndex] = React.useState(0);
const quote = quotes[index];
const next = () => setIndex((index + 1) % quotes.length);
return (
<>
;
}
```
```js
export default [
"Don’t let yesterday take up too much of today.” — Will Rogers",
"Ambition is putting a ladder against the sky.",
"A joy that's shared is a joy made double.",
];
```
```css
.fancy {
font-family: 'Georgia';
}
.title {
color: #007AA3;
text-decoration: underline;
}
.cursive {
font-style: italic;
}
.small {
font-size: 10px;
}
```
--------------------------------
### Full example of dynamic data display and inline styling in React
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/index.md
A complete demonstration of displaying dynamic user data, concatenating strings for attributes, and applying inline styles using JavaScript objects within JSX, alongside external CSS.
```js
const user = {
name: 'Hedy Lamarr',
imageUrl: 'https://i.imgur.com/yXOvdOSs.jpg',
imageSize: 90,
};
export default function Profile() {
return (
<>
{user.name}
>
);
}
```
```css
.avatar {
border-radius: 50%;
}
.large {
border: 4px solid gold;
}
```
--------------------------------
### Initial React Setup for Nested Recipe Lists
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/rendering-lists.md
This snippet provides the starting point for the exercise, including an empty React component (`App.js`) and the `recipes` data array (`data.js`) that needs to be rendered into nested lists.
```jsx
import { recipes } from './data.js';
export default function RecipeList() {
return (
Recipes
);
}
```
```javascript
export const recipes = [{
id: 'greek-salad',
name: 'Greek Salad',
ingredients: ['tomatoes', 'cucumber', 'onion', 'olives', 'feta']
}, {
id: 'hawaiian-pizza',
name: 'Hawaiian Pizza',
ingredients: ['pizza crust', 'pizza sauce', 'mozzarella', 'ham', 'pineapple']
}, {
id: 'hummus',
name: 'Hummus',
ingredients: ['chickpeas', 'olive oil', 'garlic cloves', 'lemon', 'tahini']
}];
```
--------------------------------
### Install React and React DOM packages
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/add-react-to-an-existing-project.md
Run this command in your project folder to install the `react` and `react-dom` packages, which are essential for building React applications.
```Shell
npm install react react-dom
```
--------------------------------
### Install Parcel as a development dependency
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/build-a-react-app-from-scratch.md
This command installs Parcel as a development dependency in your project. Parcel is a zero-configuration build tool that offers out-of-the-box support for features like fast refresh, JSX, and TypeScript, simplifying the setup for React applications.
```bash
npm install --save-dev parcel
```
--------------------------------
### Install React.dev Website Dependencies
Source: https://github.com/jeanduplessis/react.dev/blob/main/README.md
Navigate into the project root directory and install the necessary npm dependencies using Yarn.
```Shell
cd react.dev
yarn
```
--------------------------------
### Install React 19 and its TypeScript types
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/blog/2024/04/25/react-19-upgrade-guide.md
Commands to install React and React DOM version 19, along with their corresponding TypeScript type definitions, using either npm or Yarn. The `--save-exact` or `--exact` flag ensures that the specified major version is installed.
```bash
npm install --save-exact react@^19.0.0 react-dom@^19.0.0
```
```bash
yarn add --exact react@^19.0.0 react-dom@^19.0.0
```
```bash
npm install --save-exact @types/react@^19.0.0 @types/react-dom@^19.0.0
```
```bash
yarn add --exact @types/react@^19.0.0 @types/react-dom@^19.0.0
```
--------------------------------
### Migrating from react-test-renderer/shallow to react-shallow-renderer
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/blog/2024/04/25/react-19-upgrade-guide.md
Explains how to update test setups that use `react-test-renderer/shallow` to directly import `react-shallow-renderer`. This change reflects the removal of the re-export in React 19, preferring direct package installation.
```bash
npm install react-shallow-renderer --save-dev
```
```diff
- import ShallowRenderer from 'react-test-renderer/shallow';
+ import ShallowRenderer from 'react-shallow-renderer';
```
--------------------------------
### Complete React Example: Shared State with Lifting State Up
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/index.md
This comprehensive example demonstrates the full implementation of shared state in React using the 'lifting state up' pattern. It includes the parent component managing the state and passing it down, and child components consuming these props, resulting in synchronized updates across all instances.
```js
import { useState } from 'react';
export default function MyApp() {
const [count, setCount] = useState(0);
function handleClick() {
setCount(count + 1);
}
return (
Counters that update together
);
}
function MyButton({ count, onClick }) {
return (
);
}
```
```css
button {
display: block;
margin-bottom: 5px;
}
```
--------------------------------
### Sandpack Configuration for Imperative UI Example
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/reacting-to-input-with-state.md
This JSON file configures the Sandpack environment for the imperative UI example, specifying that hard reloads should occur on changes to ensure the example behaves as expected.
```json
{
"hardReloadOnChange": true
}
```
--------------------------------
### Complete Streaming Example with Sandpack
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/use.md
A comprehensive, runnable example showcasing the end-to-end process of streaming data. It includes the Client Component (`Message`), a container component (`MessageContainer`), and a simulated Server Component (`App`) that manages the Promise and rendering flow.
```js
"use client";
import { use, Suspense } from "react";
function Message({ messagePromise }) {
const messageContent = use(messagePromise);
return
Here is the message: {messageContent}
;
}
export function MessageContainer({ messagePromise }) {
return (
⌛Downloading message...}>
);
}
```
```js
import { useState } from "react";
import { MessageContainer } from "./message.js";
function fetchMessage() {
return new Promise((resolve) => setTimeout(resolve, 1000, "⚛️"));
}
export default function App() {
const [messagePromise, setMessagePromise] = useState(null);
const [show, setShow] = useState(false);
function download() {
setMessagePromise(fetchMessage());
setShow(true);
}
if (show) {
return ;
} else {
return ;
}
}
```
```js
import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import './styles.css';
// TODO: update this example to use
// the Codesandbox Server Component
// demo environment once it is created
import App from './App';
const root = createRoot(document.getElementById('root'));
root.render(
);
```
--------------------------------
### React Example: Updating Quantity with Actions and Transitions
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/useTransition.md
This comprehensive example demonstrates managing quantity updates in a React application using `useTransition` to show pending states. It includes multiple files for application logic, component rendering, and a simulated API call. The setup illustrates how state can be updated while asynchronous requests are in progress, but also highlights a known limitation where requests might complete out of order.
```json
{
"dependencies": {
"react": "beta",
"react-dom": "beta"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
```
```javascript
import { useState, useTransition } from "react";
import { updateQuantity } from "./api";
import Item from "./Item";
import Total from "./Total";
export default function App({}) {
const [quantity, setQuantity] = useState(1);
const [isPending, startTransition] = useTransition();
const updateQuantityAction = async newQuantity => {
// To access the pending state of a transition,
// call startTransition again.
startTransition(async () => {
const savedQuantity = await updateQuantity(newQuantity);
startTransition(() => {
setQuantity(savedQuantity);
});
});
};
return (
Checkout
);
}
```
```javascript
import { startTransition } from "react";
export default function Item({action}) {
function handleChange(event) {
// To expose an action prop, await the callback in startTransition.
startTransition(async () => {
await action(event.target.value);
})
}
return (
)
}
```
```javascript
export async function updateQuantity(newQuantity) {
return new Promise((resolve, reject) => {
// Simulate a slow network request.
setTimeout(() => {
resolve(newQuantity);
}, 2000);
});
}
```
```css
.item {
display: flex;
align-items: center;
justify-content: start;
}
.item label {
flex: 1;
text-align: right;
}
.item input {
margin-left: 4px;
width: 60px;
padding: 4px;
}
.total {
height: 50px;
line-height: 25px;
display: flex;
align-content: center;
justify-content: space-between;
}
```
--------------------------------
### Configure ESLint for React Hooks plugin
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/blog/2025/04/21/react-compiler-rc.md
Example `eslint.config.js` showing how to import and apply the recommended configurations from `eslint-plugin-react-hooks` for both Flat Config (ESLint 9+) and Legacy Config. This setup is necessary after migrating from `eslint-plugin-react-compiler`.
```JavaScript
// eslint.config.js
import * as reactHooks from 'eslint-plugin-react-hooks';
export default [
// Flat Config (eslint 9+)
reactHooks.configs.recommended,
// Legacy Config
reactHooks.configs['recommended-latest']
];
```
--------------------------------
### Install React Compiler Beta and ESLint Plugin
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/blog/2024/10/21/react-compiler-beta-release.md
Installs the beta versions of 'babel-plugin-react-compiler' and 'eslint-plugin-react-compiler' as development dependencies. This allows early adopters and library maintainers to try the compiler and provide feedback.
```bash
npm install -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta
```
```bash
yarn add -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta
```
--------------------------------
### Basic CSS Styling for React Video Player Example
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/Activity.md
Provides basic CSS rules to style the body, buttons, and video elements within the React video player example, ensuring proper layout and sizing.
```css
body { height: 275px; }
button { margin-right: 10px }
b { display: inline-block; margin-right: 10px; }
video { width: 300px; margin-top: 10px; }
```
--------------------------------
### Basic HTML Unordered List Example
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/rendering-lists.md
An example of a static HTML unordered list, illustrating how similar content is typically structured before dynamic rendering with JavaScript.
```html
Creola Katherine Johnson: mathematician
Mario José Molina-Pasquel Henríquez: chemist
Mohammad Abdus Salam: physicist
Percy Lavon Julian: chemist
Subrahmanyan Chandrasekhar: astrophysicist
```
--------------------------------
### Complete React App Example with JSX
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/createElement.md
A full, runnable example of a React application using JSX for component definition and rendering. This snippet provides a direct comparison to the `createElement` approach, including associated CSS styling.
```js
function Greeting({ name }) {
return (
Hello {name}. Welcome!
);
}
export default function App() {
return ;
}
```
```css
.greeting {
color: darkgreen;
font-family: Georgia;
}
```
--------------------------------
### React `createPortal` Usage Examples
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react-dom/createPortal.md
Demonstrates various ways to use React's `createPortal` function to render children into a different part of the DOM. Includes basic syntax, a minimal example showing import and usage with `document.body`, and a full component example illustrating how a portal allows content to 'escape' its parent's visual boundaries while maintaining React's logical tree.
```js
{createPortal(children, domNode, key?)}
```
```js
import { createPortal } from 'react-dom';
// ...
This child is placed in the parent div.
{createPortal(
This child is placed in the document body.
,
document.body
)}
```
```js
import { createPortal } from 'react-dom';
function MyComponent() {
return (
This child is placed in the parent div.
{createPortal(
This child is placed in the document body.
,
document.body
)}
);
}
```
--------------------------------
### Complete React App Example with React.createElement
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/createElement.md
A full, runnable example of a React application built entirely with `React.createElement`. It includes a functional component definition, its rendering in the main App component, and associated CSS styling.
```js
import { createElement } from 'react';
function Greeting({ name }) {
return createElement(
'h1',
{ className: 'greeting' },
'Hello ',
createElement('i', null, name),
'. Welcome!'
);
}
export default function App() {
return createElement(
Greeting,
{ name: 'Taylor' }
);
}
```
```css
.greeting {
color: darkgreen;
font-family: Georgia;
}
```
--------------------------------
### Render a basic 'Hello, world!' React component
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/add-react-to-an-existing-project.md
This example demonstrates how to set up an HTML file with a root element and a JavaScript file to import `createRoot` from `react-dom/client` and render a simple `
Hello, world
` component into the DOM.
```HTML
My app
```
```JavaScript
import { createRoot } from 'react-dom/client';
// Clear the existing HTML content
document.body.innerHTML = '';
// Render your React component instead
const root = createRoot(document.getElementById('app'));
root.render(
Hello, world
);
```
--------------------------------
### Complete React Context Highlighting Example
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/cloneElement.md
A comprehensive, runnable example showcasing the full implementation of passing highlighting data using React Context. It includes all necessary components (`App`, `List`, `Row`), context definition, sample data, and styling.
```javascript
import List from './List.js';
import Row from './Row.js';
import { products } from './data.js';
export default function App() {
return (
}
/>
);
}
```
```javascript
import { useState } from 'react';
import { HighlightContext } from './HighlightContext.js';
export default function List({ items, renderItem }) {
const [selectedIndex, setSelectedIndex] = useState(0);
return (
);
}
```
```javascript
import { useContext } from 'react';
import { HighlightContext } from './HighlightContext.js';
export default function Row({ title }) {
const isHighlighted = useContext(HighlightContext);
return (
{title}
);
}
```
```javascript
import { createContext } from 'react';
export const HighlightContext = createContext(false);
```
```javascript
export const products = [
{ title: 'Cabbage', id: 1 },
{ title: 'Garlic', id: 2 },
{ title: 'Apple', id: 3 }
];
```
```css
.List {
display: flex;
flex-direction: column;
border: 2px solid grey;
padding: 5px;
}
.Row {
border: 2px dashed black;
padding: 5px;
margin: 5px;
}
.RowHighlighted {
background: #ffa;
}
button {
height: 40px;
font-size: 20px;
}
```
--------------------------------
### Intentionally Mirroring Initial Props in React State
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/choosing-the-state-structure.md
This example illustrates a specific use case where mirroring a prop into state is acceptable: when you explicitly intend to ignore subsequent updates to that prop. By convention, the prop name should start with 'initial' or 'default' to clarify that its value is only used for initial state setup and further changes are disregarded.
```js
function Message({ initialColor }) {
// The `color` state variable holds the *first* value of `initialColor`.
// Further changes to the `initialColor` prop are ignored.
const [color, setColor] = useState(initialColor);
}
```
--------------------------------
### React Conditional Rendering Example with Multiple Components
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/understanding-your-ui-as-a-tree.md
This example demonstrates how to implement conditional rendering in a React application. It shows a main App component that uses an InspirationGenerator to dynamically display either a text quote or a color box based on data. The example includes several interconnected components (FancyText, Color, Copyright) and a data source (inspirations.js) to illustrate a complete conditional rendering flow.
```JavaScript
import FancyText from './FancyText';
import InspirationGenerator from './InspirationGenerator';
import Copyright from './Copyright';
export default function App() {
return (
<>
>
);
}
```
```JavaScript
export default function FancyText({title, text}) {
return title
?
{text}
:
{text}
}
```
```JavaScript
export default function Color({value}) {
return
}
```
```JavaScript
import * as React from 'react';
import inspirations from './inspirations';
import FancyText from './FancyText';
import Color from './Color';
export default function InspirationGenerator({children}) {
const [index, setIndex] = React.useState(0);
const inspiration = inspirations[index];
const next = () => setIndex((index + 1) % inspirations.length);
return (
<>
;
}
```
```JavaScript
export default [
{type: 'quote', value: "Don’t let yesterday take up too much of today.” — Will Rogers"},
{type: 'color', value: "#B73636"},
{type: 'quote', value: "Ambition is putting a ladder against the sky."},
{type: 'color', value: "#256266"},
{type: 'quote', value: "A joy that's shared is a joy made double."},
{type: 'color', value: "#F9F2B4"}
];
```
```CSS
.fancy {
font-family: 'Georgia';
}
.title {
color: #007AA3;
text-decoration: underline;
}
.cursive {
font-style: italic;
}
.small {
font-size: 10px;
}
.colorbox {
height: 100px;
width: 100px;
margin: 8px;
}
```
--------------------------------
### React useEffect Symmetrical Setup and Cleanup Logic
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/useEffect.md
This example illustrates the correct way to implement `useEffect` with symmetrical setup and cleanup logic. The setup phase establishes a connection, and the cleanup phase disconnects it, ensuring that resources are properly managed. The cleanup runs before re-renders with changed dependencies and on unmount.
```js
useEffect(() => {
const connection = createConnection(serverUrl, roomId);
connection.connect();
return () => {
connection.disconnect();
};
}, [serverUrl, roomId]);
```
--------------------------------
### Install React Developer Tools Standalone via npm
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/react-developer-tools.md
Instructions to install the `react-devtools` npm package globally using Yarn or npm for browsers like Safari that don't have a direct extension.
```bash
# Yarn
yarn global add react-devtools
# Npm
npm install -g react-devtools
```
--------------------------------
### Initialize a new React project with Vite
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/learn/build-a-react-app-from-scratch.md
This command uses npm to create a new React application powered by Vite. Vite is a modern build tool known for its fast development server and optimized build performance, providing a lean setup for React projects.
```bash
npm create vite@latest my-app -- --template react
```
--------------------------------
### Focusing Input Element Using React Ref Example
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react-dom/components/common.md
A complete example demonstrating how to use `useRef` to get a reference to an input DOM node and programmatically call its `focus()` method when a button is clicked.
```js
import { useRef } from 'react';
export default function Form() {
const inputRef = useRef(null);
function handleClick() {
inputRef.current.focus();
}
return (
<>
>
);
}
```
--------------------------------
### Complete Suspense-Enabled Router Example with Data Fetching
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/useTransition.md
This comprehensive multi-file JavaScript example demonstrates a fully functional React router integrated with `Suspense` and `useTransition`. It showcases how to manage application state, perform non-blocking navigations, and handle asynchronous data fetching with `use` hook and `Suspense` fallbacks. The example includes components for the main application, layout, index page, artist page, albums, biography, and a mock data fetching utility.
```js
import { Suspense, useState, useTransition } from 'react';
import IndexPage from './IndexPage.js';
import ArtistPage from './ArtistPage.js';
import Layout from './Layout.js';
export default function App() {
return (
}>
);
}
function Router() {
const [page, setPage] = useState('/');
const [isPending, startTransition] = useTransition();
function navigate(url) {
startTransition(() => {
setPage(url);
});
}
let content;
if (page === '/') {
content = (
);
} else if (page === '/the-beatles') {
content = (
);
}
return (
{content}
);
}
function BigSpinner() {
return
);
}
```
```js
export default function IndexPage({ navigate }) {
return (
);
}
```
```js
import { Suspense } from 'react';
import Albums from './Albums.js';
import Biography from './Biography.js';
import Panel from './Panel.js';
export default function ArtistPage({ artist }) {
return (
<>
{artist.name}
}>
>
);
}
function AlbumsGlimmer() {
return (
);
}
```
```js
import {use} from 'react';
import { fetchData } from './data.js';
export default function Albums({ artistId }) {
const albums = use(fetchData(`/${artistId}/albums`));
return (
{albums.map(album => (
{album.title} ({album.year})
))}
);
}
```
```js
import {use} from 'react';
import { fetchData } from './data.js';
export default function Biography({ artistId }) {
const bio = use(fetchData(`/${artistId}/bio`));
return (
{bio}
);
}
```
```js
export default function Panel({ children }) {
return (
{children}
);
}
```
```js
// Note: the way you would do data fetching depends on
// the framework that you use together with Suspense.
// Normally, the caching logic would be inside a framework.
let cache = new Map();
export function fetchData(url) {
if (!cache.has(url)) {
cache.set(url, getData(url));
}
return cache.get(url);
}
async function getData(url) {
if (url === '/the-beatles/albums') {
return await getAlbums();
} else if (url === '/the-beatles/bio') {
return await getBio();
} else {
throw Error('Not implemented');
}
}
async function getBio() {
// Add a fake delay to make waiting noticeable.
await new Promise(resolve => {
setTimeout(resolve, 500);
});
return `The Beatles were an English rock band,
formed in Liverpool in 1960, that comprised
John Lennon, Paul McCartney, George Harrison
and Ringo Starr.`;
}
async function getAlbums() {
// Add a fake delay to make waiting noticeable.
await new Promise(resolve => {
setTimeout(resolve, 3000);
});
}
```
--------------------------------
### Render Hello World with ReactDOM
Source: https://github.com/jeanduplessis/react.dev/blob/main/public/html/single-file-example.html
This snippet demonstrates how to render a simple 'Hello, world!' heading into an HTML element with the ID 'root' using ReactDOM in a React application. It's a foundational example for setting up a basic React component rendering.
```JavaScript
ReactDOM.render(
Hello, world!
, document.getElementById('root') );
```
--------------------------------
### Complete React Functional Component App Example
Source: https://github.com/jeanduplessis/react.dev/blob/main/src/content/reference/react/Component.md
A full example of the App component demonstrating the usage of the refactored ChatRoom functional component. This snippet shows how the App manages room selection and component visibility.
```javascript
import { useState } from 'react';
import ChatRoom from './ChatRoom.js';
export default function App() {
const [roomId, setRoomId] = useState('general');
const [show, setShow] = useState(false);
return (
<>