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.

Using mount on <video> with muted=true causes React console.error

See original GitHub issue

Current 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:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
davidhouwelingcommented, Jun 29, 2020

@ljharb any update on this issue?

1reaction
ljharbcommented, Dec 21, 2020

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.

Read more comments on GitHub >

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

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