arrow_backBACK TO DRILLS
Blue BeltarchitecturelockPREMIUM

defaultProps Deprecated in React 18 - Use Destructured Default Parameters Instead

A function component in a React 18 codebase is written using the legacy defaultProps pattern.

REACT_MODULE // 0x42
function Badge({ label, color }) {
return <span style={{ color }}>{label}</span>;
}
Badge.defaultProps = { color: 'gray' };

What is the recommended React 18 replacement for this pattern, and why?

lock

This Drill is Locked

This is a premium drill. Continue on to the next free drill in the sequence.

CONTINUE DRILLarrow_forward
BugDojo
BlogFAQ

© 2026. Carved in code.