Maximum update depth exceeded when using React-Router
See original GitHub issueUsing the Provider and audio hooks under React-Router produces a Maximum update depth exceeded error loop
const routes = {
'/': () => <Provider station='clouds' />,
'/:station': ({ station }) => <Provider station={station} />
}
function Provider ({ station }) {
return (
<AudioPlayerProvider>
<Radio station={station} />
</AudioPlayerProvider>
)
}
function Radio (props) {
const [song, setSong] = useState({
album: 'Press the Play button to start the radio',
title: placeholders[Math.floor(Math.random() * placeholders.length)]
})
const { togglePlayPause, ready, loading, playing, volume, mute } = useAudioPlayer({
src: `https://play.squid-radio.net/${props.station}?cache_ts=${new Date().getTime()}`,
onend: () => console.log('sound has ended!')
})
return (
<div />
)
}
const App = () => {
const routeResult = useRoutes(routes)
return routeResult || (
<script>{(
window.location.href = '/404.html'
)}
</script>
)
}
Environment (please complete the following information):
- Browser/ browser version: Firefox 81.0.2 64-bit
- Library version: 1.2.2
- React version: 16.13.1
- Node version: 14.x
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
react-router-dom Redirect causes : Maximum update depth ...
Well my instructor suggested this : https://reacttraining.com/react-router/web/api/Switch and I thought I tried this already but I read the ...
Read more >The location of the <Redirect/> will result in error( Maximum ...
The two sentences in the picture need to be exchanged, otherwise an error will be reported(Maximum update depth exceeded).
Read more >How to Fix Maximum Update Depth Exceeded in React and ...
In this video, I show you several ways the dreaded " Max Update Depth Exceeded " error commonly occurs in React and React...
Read more >React - maximum update depth exceeded - CodeProject
React. Hi, I have an error with my React app: JavaScript. <pre>index.js:1 Warning: Maximum update depth exceeded.
Read more >Fix the "Maximum Update Depth Exceeded" Error in React
React is an excellent framework, but it can have some tricky “gotchas.” One of which is when you accidentally cause an infinite render...
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
hey @jorgev259 I think I’m on to something. I should hopefully have a release out by the weekend with a fix or work-around for the issue you are having with streaming audio
I recently discovered some code that could lead to an infinite loop and fixed it in version: https://www.npmjs.com/package/react-use-audio-player/v/1.2.5
Curious if this will alleviate any of the issues mentioned above