Closed johndevor closed 2 years ago
When changing the channel
Hey there, quick questions:
https://player.twitch.tv/js/embed/v1.js
?import
statement which is probably what's causing this issue).const reloadChannel = () => {
if (!channelReloaded) {
setTimeout(() => {
setChannelReloaded(true);
}, 250);
}
};
"react-twitch-embed": "^2.1.0"
I'm not very familiar with web components. Does this mean that you're not using React to render your page?
I'm a bit surprised that the embed even shows up if you have no requests to https://embed.twitch.tv/embed/v1.js
since the component downloads this script and adds it to your HTML body the first time that componentDidUpdate()
is called.
How exactly does your project work? Like I said I'm not very familiar with web components. If I had to guess, I would say that inside TwitchEmbed
, _createEmbed()
is not being called since that method is the one that will set the this.player
object once the embed is ready. But if that was the case, I have no idea why your workaround works. Is it maybe because you're changing more props at the same time (not only channel
since the line that is throwing the error only gets executed if the only prop that changed is channel
).
I just realized why this is happening, you're updating the channel prop way too soon (before the player is initialized to be specific). I'll have to refactor the componentDidUpdate
method to avoid this error.
Ah, ok. Thanks for looking into this! That makes sense.
On Oct 8, 2020 at 6:51:30 PM, moonstar-x notifications@github.com wrote:
I just realized why this is happening, you're updating the channel prop way too soon (before the player is initialized to be specific). I'll have to refactor the componentDidUpdate method to avoid this error.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/moonstar-x/react-twitch-embed/issues/26#issuecomment-705863445, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASQMY7GAJTR5HQ2ORAFMLSJY67FANCNFSM4R47LYJA .
Hi there, sorry for the long hiatus.
I'm gonna close this issue due to inactivity. However, I have just updated this package to version 3.0.1
with #37.
Any reference to window
or document
have been moved to useEffect()
which should be executed in the client for SSR apps.
If you feel this was a mistake, feel free to re-open this issue.
Thanks!