简体   繁体   English

如何在 React JS 中访问其他组件或服务中的应用程序组件的方法

[英]How to access a method of app component in other component or service in React JS

I am working on a react application and want to implement react-notifications-component for notifications.我正在开发一个 React 应用程序,并希望为通知实现 react-notifications-component。 I don't know how to call it's addNotification method from every component.我不知道如何从每个组件调用它的 addNotification 方法。

如果你想在另一个组件中调用一个组件的函数,你必须通过props传递对它的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React.js - 如何通过ID访问组件并调用其方法? - React.js - How to access component by ID and call its method? 如何在反应路由器中从 app.js 访问组件参数 - How to access component parameters from app.js in react router 如何访问 state 变量或 React.js 中另一个组件中一个组件的 let、const、var 变量? - How to to access state variables or let,const,var variables of one component in other component in React.js? 如何通过其他React组件的方法测试React组件返回 - How to test React component return by other React component's method 如何将状态值从一个组件访问到单独文件中的其他函数(而非组件)? React JS - How to access state value from one component to other function(not component) which is in separate file? React js 如何访问其他组件道具。 (反应) - How to access other component props. (React) 如何将数组列表传递给反应js中的其他组件 - how to pass an arraylist to other component in react js ReactJS中如何访问不同组件中其他Function组件功能的方法 - How to access the method of other Function component functionality in different component in ReactJS 如何在React中访问JSX组件方法? - How to access JSX component method in React? 来自其他组件的反应组件的访问状态 - access state of react component from other component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM