Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 调用react路由以推送通知_Reactjs_Notifications - Fatal编程技术网

Reactjs 调用react路由以推送通知

Reactjs 调用react路由以推送通知,reactjs,notifications,Reactjs,Notifications,我想用php Symfony调用react路由 首先,我在react中创建了一个函数路由,如下所示: import addNotification from 'react-push-notification'; const Notifications = () => { return ( addNotification({ title: 'Notification', subtitle: 'Welcome',

我想用php Symfony调用react路由

首先,我在react中创建了一个函数路由,如下所示:

import addNotification from 'react-push-notification';

const Notifications = () => {
    return (
        addNotification({
            title: 'Notification',
            subtitle: 'Welcome',
            message: 'New message',
            native: true
        })
    )
}

export default Notifications
此函数在我调用此路由时显示通知

第二,当我尝试通过此路径访问时,我的通知会起作用,但我没有 错误:

Error: Objects are not valid as a React child (found: [object
    Promise]). If you meant to render a collection of children, use an
    array instead.
我不理解这个错误。你能帮我一下吗

第三,是否可以将此反应路线称为symfony


谢谢

您无法从组件返回对象

如果要在呈现此组件时启动通知,则需要在


请检查文档,了解react push notification@PavloZhukov的正确用法。我不想使用按钮点击。我需要在呼叫路线时显示通知。
import React, {useEffect} from 'react'
import addNotification from 'react-push-notification';

const Notifications = () => {
    useEffect(() => {
        addNotification({
            title: 'Notification',
            subtitle: 'Welcome',
            message: 'New message',
            native: true
        })
    }, [])
    return null
}

export default Notifications