const [value, setValue] = useState("");<input value={value} onChange={e => setValue(e.target.value)} />
A controlled component is one where form data is handled by React state.
✅ Best for complex forms
const inputRef = useRef();<input ref={inputRef} />
An uncontrolled component lets the DOM handle its own state.
✅ Simpler for quick forms
const MyComponent = React.memo(function MyComponent(props) {return <div>{props.name}</div>;});
A Pure Component renders the same output when given the same props and state.
🎯 Use Pure Components to improve performance by avoiding redundant rendering.
const withLogger = (WrappedComponent) => {return (props) => {console.log("Rendering", WrappedComponent.name);return <WrappedComponent {...props} />;};};
A Higher-Order Component (HOC) is a function that takes a component and returns a new component with enhanced behavior.
⚠️ Today, many HOC use cases are replaced by custom hooks, but HOCs are still common in libraries.