Using mount on <video> with muted=true causes React console.error
See original GitHub issueCurrent behavior
When using mount
on a component with a video tag which is muted, React throws an error. If the muted attribute is removed, then no error is logged.
Code example:
describe('Mounting this component causes React DOM to log an error', () => {
const Component = () => (
<video muted>
<source src="url" />
</video>
);
it('Will it?', () => {
const wrapper = mount(<Component />);
});
});
Even if the component is only <video muted />
it still happens.
Output in test:
console.error node_modules/react-dom/cjs/react-dom.development.js:530
Warning: unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.
in video (created by Comp)
in Comp (created by WrapperComponent)
in WrapperComponent
Expected behavior
There should be no printed error.
Your environment
API
- shallow
- mount
- render
Version
library | version |
---|---|
enzyme | 3.10.0 |
react | 16.12.0 |
react-dom | 16.12.0 |
react-test-renderer | 16.10.1 |
adapter (below) | 1.14.0 |
Adapter
- enzyme-adapter-react-16
PS. First time opening an issue here, I hope I didn’t miss anything
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Why `muted` attribute on video tag is ignored in React?
This is actually a known issue which has existed since 2016. The video will be muted correctly, but the property will not be...
Read more >Strict Mode - React
To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount...
Read more >How to work with React the right way to avoid some common ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >How to solve "window is not defined" errors in React and Next.js
I initially tried to do if (typeof window !== undefined) and this failed hard because of the reasons mentioned earlier. The other solutions ......
Read more >How to solve too many re-renders error in ReactJS?
After mounting a React component, it will listen to any React props or state that has changed. It will, by default, re-render the...
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 Free
Top 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
@ljharb any update on this issue?
This appears to be the same issue as https://github.com/testing-library/react-testing-library/issues/470 as well as https://github.com/facebook/react/issues/10389 - this isn’t something that’s possible to fix in enzyme.
I’ll leave #2330 open, however - if react ever fixes it, i’ll land the test case to ensure it doesn’t regress in the future.