Error with react router
See original GitHub issueDescribe the bug I get this issue when i’m switching the route.
Uncaught DOMException: Node.removeChild: The node to be removed is not a child of this node. To Reproduce Steps to reproduce the behavior: 1.Create a video component. The source can be anything, even youtube.
import { Component } from "react";
import Plyr from "plyr-react";
import 'plyr-react/dist/plyr.css';
export default class VideoPlayer extends Component {
constructor(props: any) {
super(props);
}
render() {
return (
<Plyr
source={
{
type: 'video',
title: 'Test Video',
sources: [
{
src: 'http://localhost:5000/video',
type: 'video/mp4',
size: 1080,
}
],
}
}
/>
);
}
}
2.Add routing:
import React, { Component } from 'react';
import Header from './Header';
import Users from './Users';
import { NotFoundPage } from '../pages/NotFoundPage';
import VideoPlayer from './VideoPlayer';
import {
BrowserRouter,
Switch,
Route,
Link
} from "react-router-dom";
class App extends Component<any> {
render() {
return (
<BrowserRouter>
<Header></Header>
<Switch>
<Route exact path="/" render={(props) => <Users />} />
<Route path="/watch" component={VideoPlayer} />
<Route path="*" component={NotFoundPage} />
</Switch>
</BrowserRouter>
);
}
}
export default App;
- When going to an other route from localhost/videoplayer, i get the error described above and everything freezes. I got the same issue with other react-plyr npm packages.
Expected behavior Routing and video should work normally
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
errorElement v6.6.1 - React Router
Put an errorElement at the top of your route tree and handle nearly every error in your app in one place. Or, put...
Read more >Can't resolve 'react-router-dom' - Stack Overflow
This error occurs because of react-router-dom npm package is missing. install them by using the above cmd. Share.
Read more >Error boundary causes React Router links to stop working
When React Router's location changes, the parent functional component will dismiss its error state within the useEffect hook, and it will pass ...
Read more >Module not found: Can't resolve 'react-router-dom' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'react-router-dom'", make sure to install the react-router-dom package by opening your terminal ...
Read more >Handling 404 Routes in React with a Not Found component
... for displaying an imfamous 404 Page Not Found error to the user. ... Inside the <Switch /> component from React Router, we...
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
I think when
<Plyr {...} />
gets directly REPLACED within react lifecycle, react tries to unmountvideo
but it’s just not there, asPlyr
already replaced it withdiv.plyr
😃To work-around this without a major version up (changing
<Plyr/>
to keep a topmost element) you should always replace an ancestor of<Plyr />
to avoid accessing the<video />
tag.Workaround
https://github.com/chintan9/plyr-react/issues/562#issuecomment-906618738
I had this problem today, wrapping a
div
to the component solved it.