React
React is a JavaScript library for creating user interfaces.
7th July 2022
Time to read: 1 min
What is React?
React, sometimes referred to as a frontend JavaScript framework, is a JavaScript library created by Facebook.
React is a tool for building UI components.
How does React Work?
React creates a VIRTUAL DOM in memory.
Instead of manipulating the browser's DOM directly, React creates a virtual DOM in memory, where it does all the necessary manipulating, before making the changes in the browser DOM.
React only changes what needs to be changed!
Usage
import { useState } from 'react';
import { createRoot } from 'react-dom/client';
function Counter() {
const [count, setCount] = useState(0);
return (
<>
<h1>{count}</h1>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</>
);
}
const root = createRoot(document.getElementById('root'));
root.render(<App />);
Related pages:
Create React App
Create a new React app.
React Icons
Add popular icons to your React projects. Include only the icons that your project is using.
React Share
Social media share buttons and share counts for React.
React Helmet
This reusable React component will manage all of your changes to the document head.