React Cheatsheet
React Cheatsheet
Cheatsheet
Pixaflip Technologies
Basic Concepts
React is a JavaScript library for building
user interfaces.
JSX
● JSX is a syntax extension for JavaScript
that allows you to write HTML-like
syntax within your code
02
Components
Components are the building blocks of
React applications.
//Functional Component
function Greeting(props) {
return <h1>Hello, {props.name}!</h1>;
}
//Class Component
Props
● Props are used to pass data from a
parent component to a child
component
03
function User(props) {
return (
<div>
<p>{props.name}</p> // It will print “John Doe”
</div>
);
}
ReactDOM.render(
<User name="John Doe"/>,
document.getElementById('root')
);
React Hooks
React Hooks are a set of functions that
allow functional components to have
state, lifecycle methods,
1. useState
2. useEffect
useEffect(() => {
// Side effects go here
}, [dependencies]);
04
3. useReducer
4. useMemo
5. useRef
6. useContext
7. useCallback
05