A styled-components have passing value.
Answered
Asari posted this in #help-forum
AsariOP
The component styled.div with the id of "sc-fzJBwl" has been created dynamically.
You may see this warning because you've called styled inside another component.
To resolve this only create new StyledComponents outside of any render method and function component.
How to fix this wrong ðŸ˜
You may see this warning because you've called styled inside another component.
To resolve this only create new StyledComponents outside of any render method and function component.
export default function testComponent(props: { value: number }) {
const StyledDiv = styled.div`
position: relative;
&:after {
position: absolute;
height:${props => props.value};
content: "";
}`;
const value:number = props.value;
return <StyledDiv className={`${styles.line_bar}`} value={value.toString()} />;
}How to fix this wrong ðŸ˜
Answered by Blood cockle
Hi. You need to define StyledDiv outside the function component
2 Replies
Blood cockle
Hi. You need to define StyledDiv outside the function component
Answer
@Blood cockle Hi. You need to define StyledDiv outside the function component
AsariOP
thank you so much! It work!