我有一个使用回调函数的组件,执行该组件后,我会呈现一个视频标签。但我也想在视频标签之后立即使用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/