/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import {
createContext,
memo,
useState,
useContext,
useId,
Suspense,
useEffect,
useRef,
useTransition,
} from 'react';
import cn from 'classnames';
import NextLink from 'next/link';
import ButtonLink from '../ButtonLink';
import {IconRestart} from '../Icon/IconRestart';
import BlogCard from 'components/MDX/BlogCard';
import {IconChevron} from 'components/Icon/IconChevron';
import {IconSearch} from 'components/Icon/IconSearch';
import {Logo} from 'components/Logo';
import Link from 'components/MDX/Link';
import CodeBlock from 'components/MDX/CodeBlock';
import {ExternalLink} from 'components/ExternalLink';
import sidebarBlog from '../../sidebarBlog.json';
import * as React from 'react';
import Image from 'next/image';
function Section({children, background = null}) {
return (
Create user interfaces from components
React lets you build user interfaces out of individual pieces
called components. Create your own React components like{' '}
Thumbnail, LikeButton, and{' '}
Video. Then combine them into entire screens, pages,
and apps.
Whether you work on your own or with thousands of other
developers, using React feels the same. It is designed to let you
seamlessly combine components written by independent people,
teams, and organizations.
Write components with code and markup
React components are JavaScript functions. Want to show some
content conditionally? Use an if statement.
Displaying a list? Try array map(). Learning React is
learning programming.
This markup syntax is called JSX. It is a JavaScript syntax
extension popularized by React. Putting JSX markup close to
related rendering logic makes React components easy to create,
maintain, and delete.
Add interactivity wherever you need it
React components receive data and return what should appear on the
screen. You can pass them new data in response to an interaction,
like when the user types into an input. React will then update the
screen to match the new data.
You don’t have to build your whole page in React. Add React to
your existing HTML page, and render interactive React components
anywhere on it.
Add React to your page
Go full-stack
with a framework
React is a library. It lets you put components together, but it
doesn’t prescribe how to do routing and data fetching. To build an
entire app with React, we recommend a full-stack React framework
like Next.js or{' '}
React Router.
React is also an architecture. Frameworks that implement it let
you fetch data in asynchronous components that run on the server
or even during the build. Read data from a file or a database, and
pass it down to your interactive components.
Get started with a framework
Use the best from every platform
People love web and native apps for different reasons. React
lets you build both web apps and native apps using the same
skills. It leans upon each platform’s unique strengths to let
your interfaces feel just right on every platform.
Stay true to the web
People expect web app pages to load fast. On the server,
React lets you start streaming HTML while you’re still
fetching data, progressively filling in the remaining
content before any JavaScript code loads. On the client,
React can use standard web APIs to keep your UI
responsive even in the middle of rendering.
Go truly native
People expect native apps to look and feel like their
platform.{' '}
React Native
{' '}
and{' '}
Expo{' '}
let you build apps in React for Android, iOS, and
more. They look and feel native because their UIs{' '}
are truly native. It’s not a web view—your
React components render real Android and iOS views
provided by the platform.
With React, you can be a web and a native developer. Your
team can ship to many platforms without sacrificing the user
experience. Your organization can bridge the platform silos, and
form teams that own entire features end-to-end.
Build for native platforms
Upgrade when the future is ready
React approaches changes with care. Every React commit is
tested on business-critical surfaces with over a billion
users. Over 100,000 React components at Meta help validate
every migration strategy.
The React team is always researching how to improve React.
Some research takes years to pay off. React has a high bar
for taking a research idea into production. Only proven
approaches become a part of React.
Read more React news
Latest React News
Read more React news
Join a community
of millions
You’re not alone. Two million developers from all over the
world visit the React docs every month. React is something
that people and teams can agree on.
This is why React is more than a library, an architecture, or
even an ecosystem. React is a community. It’s a place where
you can ask for help, find opportunities, and meet new
friends. You will meet both developers and designers,
beginners and experts, researchers and artists, teachers and
students. Our backgrounds may be very different, but React
lets us all create user interfaces together.
Welcome to the
React community
Get Started
>
);
}
function CTA({children, icon, href}) {
let Tag;
let extraProps;
if (href.startsWith('https://')) {
Tag = ExternalLink;
} else {
Tag = NextLink;
extraProps = {legacyBehavior: false};
}
return (
{icon === 'native' && (
)}
{icon === 'framework' && (
)}
{icon === 'code' && (
)}
{icon === 'news' && (
)}
{children}
);
}
const reactConf2021Cover = '/images/home/conf2021/cover.svg';
const reactConf2019Cover = '/images/home/conf2019/cover.svg';
const communityImages = [
{
src: '/images/home/community/react_conf_fun.webp',
alt: 'People singing karaoke at React Conf',
},
{
src: '/images/home/community/react_india_sunil.webp',
alt: 'Sunil Pai speaking at React India',
},
{
src: '/images/home/community/react_conf_hallway.webp',
alt: 'A hallway conversation between two people at React Conf',
},
{
src: '/images/home/community/react_india_hallway.webp',
alt: 'A hallway conversation at React India',
},
{
src: '/images/home/community/react_conf_elizabet.webp',
alt: 'Elizabet Oliveira speaking at React Conf',
},
{
src: '/images/home/community/react_india_selfie.webp',
alt: 'People taking a group selfie at React India',
},
{
src: '/images/home/community/react_conf_nat.webp',
alt: 'Nat Alison speaking at React Conf',
},
{
src: '/images/home/community/react_india_team.webp',
alt: 'Organizers greeting attendees at React India',
},
];
function CommunityGallery() {
const ref = useRef();
const [shouldPlay, setShouldPlay] = useState(false);
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
setShouldPlay(entry.isIntersecting);
});
},
{
root: null,
rootMargin: `${window.innerHeight}px 0px`,
}
);
observer.observe(ref.current);
return () => observer.disconnect();
}, []);
const [isLazy, setIsLazy] = useState(true);
// Either wait until we're scrolling close...
useEffect(() => {
if (!isLazy) {
return;
}
const rootVertical = parseInt(window.innerHeight * 2.5);
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
setIsLazy(false);
}
});
},
{
root: null,
rootMargin: `${rootVertical}px 0px`,
}
);
observer.observe(ref.current);
return () => observer.disconnect();
}, [isLazy]);
// ... or until it's been a while after hydration.
useEffect(() => {
const timeout = setTimeout(() => {
setIsLazy(false);
}, 20 * 1000);
return () => clearTimeout(timeout);
}, []);
return (