Answer the question
In order to leave comments, you need to log in
Why doesn't Preact render the component inside the StyledComponents wrapper?
Tried to translate an existing small react library into Preact.
While rendering inside normal tags, everything works, "Works" is displayed, but when you try to wrap it in a primitive StyledComponent, it initially rendered Do not work, so it hangs further, while the first line has changed to Works. Changing the condition occurs asynchronously.
With what it can be connected?
Moreover, if this Styled wrapper is recreated every time in the render, then everything works as it should. And if you declare before the class of the component - then the wrong behavior.
const TestStyledWrapper = styled.div`
color: red;
`;
{ condition === true ? <div>Works</div> : <div>Do not work</div> }
<TestStyledWrapper>
{ condition === true ? <div>Works</div> : <div>Do not work</div> }
</TestStyledWrapper>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question