- How to Trigger React Error Boundary (Dev and Test)· 4 min read
Trigger a React error boundary by throwing during render, testing the fallback in Jest, and using showBoundary for async or event-handler errors.
- Check If Clicked Element Is Descendant Close On Click Outside· 3 min read
Detect a click outside a modal or dropdown in React with Node.contains(), and close it by checking if the clicked element is a descendant.
- Eslint Enforce Named Function In Useeffect· 2 min read
Anonymous functions in useEffect show up as 'Anonymous function' in stack traces. Three ways to name your effect functions: a plugin, a rule, or a pattern.
- Fix useRef "Property does not exist on type 'never'"· 3 min read
useRef(null) types ref.current as null, so an if check narrows it to 'never'. Pass the element type with useRef<HTMLInputElement>(null), or JSDoc in .jsx.