React antipattern: no boolean for a child
Published in
1 min readFeb 10, 2023
If you pass a boolean prop to a child this might be a red flag that something is about to go wrong.
const Parent = () => {
...
const candies = buyCandies(money);
...
return <Child
food={candies}
canOnlyHaveIceCream={consultTheOtherParentAboutIceCream()}
/>
}
const Child = ({food, canOnlyHaveIceCream}) => {
if (canOnlyHaveIceCream) {
return <Eat…