useDailyEvents not emitting "joined-meeting" event on Call.js view

Hi,

using the daily react hooks, the useDailyEvents hook is not emitting the "joined-meeting" event on the Call.js view.

I tested this behaviour with the actual repository, and latest versions:

"@daily-co/daily-js": "^0.44.1",

"@daily-co/daily-react": "^0.7.3"

Thanks

Comments

  • christian
    christian Dailynista

    Hi @Daniel808,

    this sounds like the Call component, where the event listener is being setup from, might be rendered after the joined-meeting event was already emitted.

    Can you verify the event is emitted in a component higher up in the component tree?

    It's important to know that event listeners setup using the useDailyEvent and useThrottledDailyEvent hooks are time-sensitive, meaning that they are setup at the time the component or hook using them renders.

  • The useDailyEvents should be useful in the DailyProvider Component as far as i understand it? But they are not working.

  • christian
    christian Dailynista

    All hooks contained in the Daily React library only really work, when called from a component rendered inside the DailyProvider. The component that renders DailyProvider itself, can't utilize the hooks, because it's missing the contexts created by DailyProvider.

    So e.g. this does not work:

    const App = ({ children }) ⇒ {
      // ❌ No event context
      useDailyEvent('joined-meeting', useCallback(…));
        
      return (
        <DailyProvider>
          {children}
        </DailyProvider>
      )
    }
    

    But this does:

    const MainHandlers = () ⇒ {
      // ✅ Rendered inside DailyProvider
      useDailyEvent('joined-meeting', useCallback(…));
    }
    
    const App = ({ children }) ⇒ {  
      return (
        <DailyProvider>
          <MainHandlers />
          {children}
        </DailyProvider>
      )
    }
    

    Hope this clarifies it a bit. Let me know if there's any further questions!

    Christian