I need to check if bits are enabled. I’m currently calling “features.isBitsEnabled” in my class constructor:
export default class App extends React.Component {
constructor(props) {
this.twitch = window.Twitch ? window.Twitch.ext : null
if (this.twitch.features.isBitsEnabled) {
// Do something
Is the helper going to be null/undefined in the constructor? Should I wait until “componentDidMount()” to call it? I’m not sure this can be tested accurately in the Dev Rig.
I’m hoping someone can confirm this for me: I am now seeing in the Developer Rig that calling window.Twitch.ext.features.isBitsEnabled is ‘false’ when you call it in the constructor, or early on in the loading process. When I call it inside render, I’m seeing window.Twitch.ext.features.isBitsEnabled is ‘true’. So this tells me two things:
- Calling ‘isBitsEnabled’ in the Rig will return true even if your channel doesn’t actually have bits enabled.
- When you call ‘isBitsEnabled’, it may not return the correct value until the extension helper has fully loaded…is there a way to know when this is?
The rig returns what you set in the context/settings of the view. Not what the channel actually has or has not.
So this is a simulation of the permission buttons.
The extension helper is ready when the onAuthorised
callback is triggered.
Got it, everything makes sense now!