Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Use a default in the parameter destructuring, such as function Button({ size = "md" }); it applies only when the prop is undefined, not when it is null.
In function components the usual approach is JavaScript default parameters in destructuring: function Avatar({ size = 48 }). The default is used when the prop is missing or explicitly undefined. Passing null or 0 counts as a real value, so the default is not applied. Keep defaults for objects and arrays outside the component or in useMemo if they are used in effect dependencies, because a new object literal on each render has a new identity.