0

I have a box component. I need to hide it if props are false and show if one of them is true. But when props are true, it is hidden. But when I switch to another component and return to those with boxes, it becomes visible.

<Box                              
            component={Grid}
            display={{
              xs: error || activity ? "block" : "none",
              sm: error || activity ? "block" : "none",
              md: "block",
            }}
           
          >
            <Component/>
          </Box> 
Viswanatha Swamy
  • 699
  • 1
  • 10
  • 17
Festina
  • 327
  • 3
  • 17

1 Answers1

1

It would be easier to just use a condition in your return to display it or not.

function theBox(props){
  return (
  { props.display &&
         <Box                              
            component={Grid}
            display={{
              xs: error || activity ? "block" : "none",
              sm: error || activity ? "block" : "none",
              md: "block",
            }}
          >
            <Component/>
          </Box> 
  }
 );
}
Raythe
  • 472
  • 5
  • 19