React npm



React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.

Declarative views make your code more predictable and easier to debug.


Build encapsulated components that manage their own state, then compose them to make complex UIs.

Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.

Learn Once, Write Anywhere

We don’t make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code.

React can also render on the server using Node and power mobile apps using React Native.

A Simple Component

React components implement a method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by via .

JSX is optional and not required to use React. Try the Babel REPL to see the raw JavaScript code produced by the JSX compilation step.

Loading code example...

A Stateful Component

In addition to taking input data (accessed via ), a component can maintain internal state data (accessed via ). When a component’s state data changes, the rendered markup will be updated by re-invoking .

Loading code example...

An Application

Using and , we can put together a small Todo application. This example uses to track the current list of items as well as the text that the user has entered. Although event handlers appear to be rendered inline, they will be collected and implemented using event delegation.

Loading code example...

A Component Using External Plugins

React allows you to interface with other libraries and frameworks. This example uses remarkable, an external Markdown library, to convert the ’s value in real time.

Loading code example...


React · GitHub licensenpm versionCircleCI StatusPRs Welcome

React is a JavaScript library for building user interfaces.

  • Declarative: React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable, simpler to understand, and easier to debug.
  • Component-Based: Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.
  • Learn Once, Write Anywhere: We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code. React can also render on the server using Node and power mobile apps using React Native.

Learn how to use React in your own project.


React has been designed for gradual adoption from the start, and you can use as little or as much React as you need:

You can use React as a tag from a CDN, or as a package on npm.


You can find the React documentation on the website.

Check out the Getting Started page for a quick overview.

The documentation is divided into several sections:

You can improve it by sending pull requests to this repository.


We have several examples on the website. Here is the first one to get you started:

functionHelloMessage({ name }){return<div>Hello {name}</div>;}ReactDOM.render(<HelloMessagename="Taylor"/>,document.getElementById('container'));

This example will render "Hello Taylor" into a container on the page.

You'll notice that we used an HTML-like syntax; we call it JSX. JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. If you're using React as a tag, read this section on integrating JSX; otherwise, the recommended JavaScript toolchains handle it automatically.


The main purpose of this repository is to continue evolving React core, making it faster and easier to use. Development of React happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving React.

Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React.

Good First Issues

To help you get your feet wet and get you familiar with our contribution process, we have a list of good first issues that contain bugs which have a relatively limited scope. This is a great place to get started.


React is MIT licensed.

  1. Boderlands 3
  2. Arjuna alter
  3. 1992 tattoo
  4. Razer inc

Publish React components as an npm package

This article will review how to publish React components as an npm package with Babel 7 (the latest version at the time of writing) and common errors.

I found myself copy-pasting my React components from project to project and wanted to create an npm package so I could import them easily. To do that, I had to learn how to publish an npm package. It was hard to find much updated info online about publishing React components with Babel 7, and I was getting plenty of build errors, so I decided to write this as a reference. This is going to assume React competence, but little-to-no experience using npm.

Take a look at the final npm package and GitHub repo


  • Create an npm account and login. You can either login from the npm website or from the CLI by running .
  • A React app. I created the boilerplate for this article with . Run the app on your local machine.

1. Create and isolate components to publish

In the boilerplate app, I went into the src folder and deleted everything besides App.js, app.css, and index.js.

I also added a folder called that will store everything I want to publish on npm. Inside , there is a folder called to store the component elements and a file called to export them. (This seems to be a standard, based on other tutorials and the Carbon’s library.)

Inside the components folder, I create new files called and , which will be the components to use from the npm package. The code for these components isn’t very important, but I’ll list it below.

> Button.js

import React from 'react';const Button = (props) => {
return (
<button className={`btn btn--${props.kind} CTA`}
}export default Button;

> Badge.js

import React from 'react';const Badge = (props) => {
return (
<div className={`badge ${!props.value ? 'badge--none' :''} `}
<h4 className="heavy">{props.value || 0}</h4>
}export default Badge;

IMPORTANT: To style these components, they will either need 1. css imported directly into the component, 2. inline styles, which can be applied directly to the components or with the help of a css-in-js package like styled-components, or 3. pre-compiled and bundled sass/scss, which I believe can be applied in a React app with a sass-loader but is outside the scope of this article.

These components are both in the folder. Then, we’ll add them to the index.js file:

import Badge from './components/Badge';
import Button from './components/Button';export { Badge, Button };

1b. Create a repo for the components

This is technically optional, since components don’t have to be on Github for them to be published in npm. But it’s very convenient, because the README for your repo will automatically be populated as the package’s documentation in npm.

2. Install Babel and build the folder

To install Babel, run the following in the CLI:

npm install --save-dev @babel/core @babel/cli @babel/preset-env npm install -save @babel/polyfill

Using the versions of babel that begin with @ signs is important for matching the presets. Either way, using unscoped versions of Babel (without @ signs) and scoped presets (designated with @ signs) will cause build errors.

In the top-level folder of your project, add a file called and add the following presets:

"presets": [
"targets": {
"edge": "17",
"firefox": "60",
"chrome": "67",
"safari": "11.1"
"useBuiltIns": "usage",
"corejs": "3.6.5"

tells the browser which versions it should target, and allows Babel to compile JSX.

In , under , replace the build script with the following:

"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files";

This will copy the to a new folder called . This folder is invisible but will be added to your root folder after build.

Run the command in the CLI.

If your build was successful and you write in the root folder, you will see a new folder called :

3. Alter the package.json for publishing

This is the good part! The must be changed to publish to npm.

This is the first part of my :

"name": "npm-test",
"version": "0.1.0",
"private": true,

The here has to be a unique name that hasn’t been taken by an existing npm package (you can check if a name is taken using npm search). is the package version, and must be changed whenever it’s republished. Version syntax indicates major, minor, and patch releases and more about it can be found here in the npm docs.

, , and are all optional fields that will give potential end users a better idea of the package. Full here.

"name": "jawblia",
"description": "Two test React components",
"author": "Jawblia",
"keywords": ["react", "components", "ui"],
"version": "0.1.0",
"private": false,
"main": "dist/index.js",
"module": "dist/index.js",
"files": [ "dist", "" ],
"repository": {
"type": "git",
"url": "git+"

The file is ready for .

4. Use the new package

Check in the CLI and on your npm profile that the package has published. To make sure it’s working, open a different project on your local machine, and try to use the package:

In the new project, try to use one of your components by importing it:

> App.js

import { Button } from 'jawblia';
import Flex from './layout/Flex';function App() {return (
<Flex middle center column className="page" gap={1.5}>
<h3>This is my new project</h3>
<Button label="test" kind="primary"/>
</Flex>);}export default App;

In the browser, we see:

We’re able to use any of the props in the original component and change the label, type, and style of the button. The npm package is working.

Coda: Some caveats

There’re a few things missed here worth mentioning.


If you import your new package, you’ll notice a warning like this:

All React npm packages are also premised to be used with Typescript. Declaring types for a package involves creating a declaration file and adding it in package.json with the key. Alternatively, you don’t need to declare types, but Typescript users will have to declare their own.


I used scss for the styling on my components, and added a separate folder in the folder called . This styling all compiles into the App.css sheet in the main src folder. If you don’t want the scss to precompile, I found this Stack Overflow answer addressing it.

Babel versions:

If your preset syntax and imported Babel versions aren’t aligned you will likely get an error message like:

ReferenceError: [BABEL] src/lib/index.js: Unknown option: /Users/juliabell/skylight/node_modules/babel-preset-react-app/index.js.overrides. Check out [<>](<>) for more information about options.A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:Invalid: { presets: [{option: value}] } Valid: { presets: [['presetName', {option: value}]] }


Requires Babel “7.0.0-0” but was loaded with “6.26.3” #8482

From looking online it seemed like these errors can be caused by having different versions of babel installed globally vs. locally, having a or file in the parent folder, or using incorrect syntax with the presets. In my case, I was using incorrect syntax in presets and adding scoped Babel versions () when I had originally installed unscoped Babel versions ().


It’s recommended that npm packages use a license to define their use. I didn’t add one, but the Ben Awad video linked below explains how to do so.




Official React bindings for Redux.
Performant and flexible.

GitHub Workflow Statusnpm versionnpm downloadsredux channel on discord


Using Create React App

The recommended way to start new apps with React Redux is by using the official Redux+JS template for Create React App, which takes advantage of Redux Toolkit.

npx create-react-app my-app --template redux

An Existing React App

React Redux 7.1 requires React 16.8.3 or later.

To use React Redux with your React app, install it as a dependency:

# If you use npm: npm install react-redux # Or if you use Yarn: yarn add react-redux

You'll also need to install Redux and set up a Redux store in your app.

This assumes that you’re using npm package manager with a module bundler like Webpack or Browserify to consume CommonJS modules.

If you don’t yet use npm or a modern module bundler, and would rather prefer a single-file UMD build that makes available as a global object, you can grab a pre-built version from cdnjs. We don’t recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on npm.

React Native

As of React Native 0.18, React Redux 5.x should work with React Native. If you have any issues with React Redux 5.x on React Native, run and make sure you don’t have a duplicate React installation in your . We recommend that you use which is better at avoiding these kinds of issues.


The React Redux docs are now published at .

We're currently expanding and rewriting our docs content - check back soon for more updates!

How Does It Work?

We do a deep dive on how React Redux works in this readthesource episode.

Also, the post The History and Implementation of React-Redux explains what it does, how it works, and how the API and implementation have evolved over time.





Npm react

Create a New React App

Use an integrated toolchain for the best user and developer experience.

This page describes a few popular React toolchains which help with tasks like:

  • Scaling to many files and components.
  • Using third-party libraries from npm.
  • Detecting common mistakes early.
  • Live-editing CSS and JS in development.
  • Optimizing the output for production.

The toolchains recommended on this page don’t require configuration to get started.

You Might Not Need a Toolchain

If you don’t experience the problems described above or don’t feel comfortable using JavaScript tools yet, consider adding React as a plain tag on an HTML page, optionally with JSX.

This is also the easiest way to integrate React into an existing website. You can always add a larger toolchain if you find it helpful!

Recommended Toolchains

The React team primarily recommends these solutions:

  • If you’re learning React or creating a new single-page app, use Create React App.
  • If you’re building a server-rendered website with Node.js, try Next.js.
  • If you’re building a static content-oriented website, try Gatsby.
  • If you’re building a component library or integrating with an existing codebase, try More Flexible Toolchains.

Create React App

Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in React.

It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 14.0.0 and npm >= 5.6 on your machine. To create a project, run:


on the first line is not a typo — it’s a package runner tool that comes with npm 5.2+.

Create React App doesn’t handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. Under the hood, it uses Babel and webpack, but you don’t need to know anything about them.

When you’re ready to deploy to production, running will create an optimized build of your app in the folder. You can learn more about Create React App from its README and the User Guide.


Next.js is a popular and lightweight framework for static and server‑rendered applications built with React. It includes styling and routing solutions out of the box, and assumes that you’re using Node.js as the server environment.

Learn Next.js from its official guide.


Gatsby is the best way to create static websites with React. It lets you use React components, but outputs pre-rendered HTML and CSS to guarantee the fastest load time.

Learn Gatsby from its official guide and a gallery of starter kits.

More Flexible Toolchains

The following toolchains offer more flexibility and choice. We recommend them to more experienced users:

  • Neutrino combines the power of webpack with the simplicity of presets, and includes a preset for React apps and React components.
  • Nx is a toolkit for full-stack monorepo development, with built-in support for React, Next.js, Express, and more.
  • Parcel is a fast, zero configuration web application bundler that works with React.
  • Razzle is a server-rendering framework that doesn’t require any configuration, but offers more flexibility than Next.js.

Creating a Toolchain from Scratch

A JavaScript build toolchain typically consists of:

  • A package manager, such as Yarn or npm. It lets you take advantage of a vast ecosystem of third-party packages, and easily install or update them.
  • A bundler, such as webpack or Parcel. It lets you write modular code and bundle it together into small packages to optimize load time.
  • A compiler such as Babel. It lets you write modern JavaScript code that still works in older browsers.

If you prefer to set up your own JavaScript toolchain from scratch, check out this guide that re-creates some of the Create React App functionality.

Don’t forget to ensure your custom toolchain is correctly set up for production.

Is this page useful?Edit this page


Getting Started

Create React App is an officially supported way to create single-page React applications. It offers a modern build setup with no configuration.

Quick Start#

npx create-react-app my-app

cd my-app

npm start

If you've previously installed globally via , we recommend you uninstall the package using or to ensure that always uses the latest version.

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

Then open http://localhost:3000/ to see your app.

When you’re ready to deploy to production, create a minified bundle with .

npm start

Get Started Immediately#

You don’t need to install or configure tools like webpack or Babel. They are preconfigured and hidden so that you can focus on the code.

Create a project, and you’re good to go.

Creating an App#

You’ll need to have Node >= 10 on your local development machine (but it’s not required on the server). You can use nvm (macOS/Linux) or nvm-windows to switch Node versions between different projects.

To create a new app, you may choose one of the following methods:


npx create-react-app my-app

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)


npm init react-app my-app

is available in npm 6+


yarn create react-app my-app

is available in Yarn 0.25+

Selecting a template#

You can now optionally start a new app from a template by appending to the creation command.

If you don't select a template, we'll create your project with our base template.

Templates are always named in the format , however you only need to provide the to the creation command.

npx create-react-app my-app --template [template-name]

You can find a list of available templates by searching for "cra-template-*" on npm.

Our Custom Templates documentation describes how you can build your own template.

Creating a TypeScript app#

You can start a new TypeScript app using templates. To use our provided TypeScript template, append to the creation command.

npx create-react-app my-app --template typescript

If you already have a project and would like to add TypeScript, see our Adding TypeScript documentation.

Selecting a package manager#

When you create a new app, the CLI will use Yarn to install dependencies (when available). If you have Yarn installed, but would prefer to use npm, you can append to the creation command. For example:

npx create-react-app my-app --use-npm


Running any of these commands will create a directory called inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies:



├── node_modules

├── package.json

├── .gitignore

├── public

│ ├── favicon.ico

│ ├── index.html

│ ├── logo192.png

│ ├── logo512.png

│ ├── manifest.json

│ └── robots.txt

└── src

├── App.css

├── App.js

├── App.test.js

├── index.css

├── index.js

├── logo.svg

├── serviceWorker.js

└── setupTests.js

No configuration or complicated folder structures, only the files you need to build your app. Once the installation is done, you can open your project folder:


Inside the newly created project, you can run some built-in commands:

or #

Runs the app in development mode. Open http://localhost:3000 to view it in the browser.

The page will automatically reload if you make changes to the code. You will see the build errors and lint warnings in the console.

Build errors

or #

Runs the test watcher in an interactive mode. By default, runs tests related to files changed since the last commit.

Read more about testing.

or #

Builds the app for production to the folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.

Your app is ready to be deployed.


You will also be interested:

Although there were some murky rumors that at some prom, a sexy teacher was allowed in a circle, and then blackmailing. With a video, was given to the fang, but the current students of the school did not have accurate information. Immediately after getting off the bus to the woman, despite the presence of children - adult sons and a husband.

They began to pester me.

824 825 826 827 828