SyntaxStudy
Sign Up
Home React Reference

React Reference

12 entries — click any item for full details and examples

Hooks

Name Description
useState() React 16.8 Adds local state to a function component. Returns current state and a function to update it.
useEffect() React 16.8 Runs side effects after render. The dependency array controls when it re-runs.
useContext() React 16.8 Subscribes to a React context. Avoids prop drilling for global data like themes or auth state.
useRef() React 16.8 Returns a mutable ref object. Used to access DOM elements or store mutable values that do not trigger re-render.
useMemo() / useCallback() React 16.8 useMemo caches an expensive computed value; useCallback caches a function reference between renders.
useReducer() React 16.8 An alternative to useState for complex state logic. Similar to Redux pattern.

Component APIs

Name Description
props Props are read-only inputs to components. Use destructuring for cleaner syntax. Default values prevent undefined errors.
children prop The children prop passes JSX between component tags. Used to build wrapper/layout components.
React.memo() Wraps a component to prevent unnecessary re-renders when props have not changed.

JSX

Name Description
Conditional rendering Render elements conditionally using logical &&, ternary operator, or if statements.
List rendering Render arrays of elements using .map(). Always provide a unique key prop for performance.
Event handling React events are camelCase and take a function. Use e.preventDefault() for forms. Avoid inline functions in loops.