How can I stop styled-components from passing some props to the DOM?
April 4, 2019 at 2:48pmHow can I stop styled-components from passing some props to the DOM?
April 4, 2019 at 2:48pmI am using styled-system to add some responsiveness props like this to my styled components:
display={{ xs: "none", sm: "block" }}
But styled components passes the display prop to the DOM, so the rendered component has this attribute:
display="[object Object]"
According to this issue https://github.com/styled-system/styled-system/issues/280 this is related to how the HOCs in styled-components work, so does anyone know how I could fix this?
April 5, 2019 at 1:27am
Can you have minimal reproduction in codesandbox? On the issue you linked it is with
emotion
and react-emotion
. I have a feeling that if you are using styled-components
then attrs should work to control the attributes that should be merge on your componentApril 5, 2019 at 8:57am
I’m not sure how attrs would work since I’m trying to prevent some attrs to end up into the DOM
April 14, 2019 at 11:30am