Skip to content

Channel is null when using useEchoModel for notifications #433

Closed
@thoresuenert

Description

@thoresuenert

Echo Version

2.1.3

Laravel Version

11.44.7

PHP Version

8.4

NPM Version

10.9.2

Database Driver & Version

No response

Description

When using notifications with echo-react, the docs say:

import { useEchoModel } from "@laravel/echo-react";

 

const { channel } = useEchoModel('App.Models.User', userId);

 

channel().notification((notification) => {

    console.log(notification.type);

});

The function call channel() returns null until you wrap the call in useEffect.

Is that intentional?

Steps To Reproduce

laravel new project
php artisan broadcast:install

use reverb with echo-react.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions