reactjs - 如何在JSX中的arrow函数内调用另一个函数?

标签 reactjs electron

我有一个使用回调函数的组件,执行该组件后,我会呈现一个视频标签。但我也想在视频标签之后立即使用ipcRenderer.send,但不知道如何正确编写它以使其实现。

        <div className="main-user-video">
          {/* TODO: Use WebRTC.onCallUserAdded to add another and add another video with the new remoteStream */}
              <video
                id="video_player"
                className="main-user-video"
                // style={
                //   this.state.knocking.callAccepted
                //     ? null
                //     : { filter: "grayscale(100%)" }
                // }
                controls={false}
                ref={this.remoteVideo}
                autoPlay={true}
              ></video>
                {WebRTC.onCallUserAdded((err, callId, userId, audio, video, remoteStream, usersInCall) =>
                  <video
                  id="video_player"
                  className="main-user-video"
                  controls={false}
                  ref={remoteStream}
                  autoPlay={true}
                ></video>
                {(usersInCall > 2) ? electron.ipcRenderer.send("MULTI-PARTY-CALL") : null}
                )}
        </div>
在第二个视频标签之后,就是我要使用ipcRenderer的地方。

最佳答案

箭头函数是返回值的函数的简写。

() => <video/>
等于
() => {
  return <video/>
}
您可以在返回之前在街区中做任何您想做的事
() => {
  // call function or any process
  return <video/>
}

关于reactjs - 如何在JSX中的arrow函数内调用另一个函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65583787/

相关文章:

javascript - React-Redux - 在异步数据到达之前传递 props

javascript - 让我的日期选择器传递他的值(value)时遇到麻烦

javascript - 如何从渲染器进程调用 Electron API 方法?

electron - 如何确定应用程序是否由 Electron 构建?

reactjs - 检查 React 组件的类型

javascript - react : avoid child component rerender on state change

node.js - 从 Node.JS 服务器重定向到路由不会呈现下一页

javascript - 单击按钮但不打开窗口或链接 Electron

javascript - 如何删除在 Electron 中从 index.html 到 contact.html 的转换过程中创建的空白页?

javascript - 清除html中的 Canvas 在 Electron 中没有滚动时不会刷新