javascript - 如果调用另一个组件的套接字函数,则在屏幕区域执行行。-React-Native
问题描述
我有一个外部套接字功能
export default class SocketInstance
{
static getSocketInstance()
{
...
}
...
listen(aState)
{
...
return !aState
}
}
然后在我的屏幕区域
从 '.../...' 导入 SocketInstance;
export default class screenArea extends Component
{
screenArea()
{
this.state={
theState: false
}
}
render()
{
return(....)
}
componentDidMount()
{
this.socket = SocketInstance.getSocketInstance();
const getReturningState = this.socket.listen(this.state.theState)
console.warn(getReturningState) //Only print initially but not after the listen is triggered
}
}
为简单起见,有没有办法在触发 get listen 后获取 screenArea 中打印的状态?再次为简单起见,我使用的是 print,但我需要在 screenArea 中执行其他操作。
解决方案
推荐阅读
- google-sheets - 通过 Google 脚本 HTTP GET 到 Binance API
- elasticsearch - Elasticsearch 查询将多个值匹配到单个字段
- java - 如何以有效的方式从 Firebase 数据库中检索数据
- python - 使用 Django3.1 时无法显示传递给模板的上下文
- python - 如何为调用 SetWindowCompositionAttribute 的窗口实现圆角
- elasticsearch - 用于不确定量 i18n 的 Elasticsearch
- ios - 如何从 Firestore 检索自动生成的 documentID,以重用 documentID,因此我的数据不会被替换
- python - 如何忽略正则表达式中不需要的模式
- c++ - 为什么在这种情况下模板参数是参考?
- python - 如何从字典的字典列表中提取元素