Reactjs 调用react路由以推送通知
我想用php Symfony调用react路由 首先,我在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',
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