[styled-engine] Conflict between the styled API of emotion and forwardRef prop-type
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Emotion doesn’t use the React.forwardRef primitive on the server: https://github.com/emotion-js/emotion/blob/10514a8635dcaa55b85c7bff90e2a9e14d1ba61f/packages/core/src/context.js#L39. This creates a conflict with our accepting ref logic
cc @Andarist
Expected Behavior 🤔
No warning
Steps to Reproduce 🕹
Render the following server-side
import React from 'react';
import { elementTypeAcceptingRef, elementAcceptingRef } from '@material-ui/utils';
import { experimentalStyled as styled } from '@material-ui/core/styles';
// or import styled from '@emotion/styled';
const Div = styled('div')`
width: 20px;
height: 20px;
background: red;
`
function Tooltip(props) {
return props.children;
}
Tooltip.propTypes = {
children: elementAcceptingRef,
component: elementTypeAcceptingRef,
};
export default function Demo() {
return <Tooltip component={Div}><Div>hello</Div></Tooltip>
}
Context 🔦
Found in https://github.com/mui-org/material-ui/pull/22876#issuecomment-706577807.
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v5.0.0-alpha.12 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (9 by maintainers)
Top Results From Across the Web
[styled-engine] Conflict between the styled API of emotion and ...
[styled-engine] Conflict between the styled API of emotion and forwardRef prop-type #23070 · Comments · Current Behavior · Expected Behavior.
Read more >Emotion styled component and React.forwardRef not working ...
I'm trying to write two React styled components (with Emotion 10), specifying some custom render logic into one of them, and preserving the ......
Read more >@mui/styled-engine | Yarn - Package Manager
This package is a wrapper around the @emotion/react package. It also provides a shared interface that can be used with other styled engines,...
Read more >How to use the @emotion/styled.button function in ... - Snyk
To help you get started, we've selected a few @emotion/styled.button examples, ... react/forbid-prop-types forwardRef: PropTypes.object }; ToolbarButton.
Read more >@material-ui/core - Awesome JS
The breaking change is regarding an experimental API: -import { styled, experimental_sx } from '@mui/material/styles'; +import { styled } from ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’re not warning in node now which should sufficiently approximate
react-dom/server
usage. The rest is up to https://github.com/facebook/react/issues/20047If you insist on keeping this workaround without confirming with React then could you please export the same checker so that we can re-use it? That way we can make sure we don’t over-fire the warning and hope that it doesn’t hide actual issues. The goal is that we don’t have to maintain this technique.