question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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>
}
Capture d’écran 2020-10-15 à 16 27 28 Capture d’écran 2020-10-15 à 16 27 36

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
eps1loncommented, Oct 17, 2020

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/20047

0reactions
eps1loncommented, Oct 16, 2020

If 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found