cpunion/react-actioncable-provider

TypeError: Cannot read property 'cable' of undefined

mollerjorge opened this issue · 0 comments

We are getting the following error sporadically:

TypeError: Cannot read property 'cable' of undefined

This is how we use the ActionCableProvider

import ActionCable from "actioncable"
import { ActionCableProvider } from "react-actioncable-provider"

const Provider = props => {
       const cable = ActionCable.createConsumer(
      `${baseURL}?uid=${uid}&access-token=${accessToken}&client=${client}`
    )
    return <ActionCableProvider cable={cable}>{children}</ActionCableProvider>
}

We import the provider and use it like this in the entry point of our App:

import CableProvider from "./ActionCable/ActionCableProvider"

class App extends Component {
  render = () => (
    <div style={{ height: "100%" }}>
      <CableProvider>
        <Switch>
          <Route path="/sign-in" component={myCompnent} />
           ...
          </Switch>
      </CableProvider>
    </div>
  )
}

export default App

React version : 16.8.6
react-actioncable-provider : 2.0.0
actioncable: 5.2.3

We tried passing undefined to the ActionCableProvider just to trigger the exception, but we were unable to reproduce it.

Can someone please shed some light on why this might be happening?
Thanks!