S
S
ShamanR2019-10-02 12:01:38
JavaScript
ShamanR, 2019-10-02 12:01:38

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>

I use:
"preact": "10.0.0-rc.3",
"react": "16.9.0",
"styled-components": "4.3.2", Alias ​​set resolve: { alias: { react: '
preact /compat', 'react-dom': 'preact/compat' } },

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question