videosdk.live 的 React 本机示例代码返回错误"Invalid hook call. Hooks can only be called inside..."



我已经下载了Videosdk.live的示例代码。我下载的2个示例代码是SERVER的示例代码(videosdk-rtc-nodejs-sdk-example)和REACT-NATIVE的示例代码(videosdk-rtc-react-native-sdk-example-master)。

我首先通过npm start运行SERVER代码,它启动服务器在localhost:9000侦听任何api调用,当然要确保添加我的api KEY等。

然后启动REACT-NATIVE代码。然后,REACT-NATIVE应用程序成功地调用服务器以获取TOKEN,然后成功地调用示例中提供的validateMeeting函数,该函数实际上创建了一个新的会议。会议的id然后保存到代码中的一个名为meetingId的变量中。

然后最后使用有效的meetingId,示例代码最终使用videosdk提供的钩子。live来开始会议,例如MeetingProvider然而,这是错误发生的时候.....

这是发生错误的代码部分:

return token ? (
<SafeAreaView style={{ flex: 1, backgroundColor: '#F6F6FF' }}>
<MeetingProvider
config={{
meetingId: meetingId,
micEnabled: false,
webcamEnabled: true,
name: 'Test User',
notification: {
title: 'Code Sample',
message: 'Meeting is running.',
},
}}
token={token}
>
<MeetingContainer setToken={setToken} />
</MeetingProvider>
</SafeAreaView>
) : null

显示的是实际的错误:

>     ExceptionsManager.js:180 Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could
> happen for one of the following reasons:
>     1. You might have mismatching versions of React and the renderer (such as React DOM)
>     2. You might be breaking the Rules of Hooks
>     3. You might have more than one copy of React in the same app
>     See https://fb..... for tips about how to debug and fix this problem.
>     
>     This error is located at:
>         in MeetingProvider (at react-native-sdk/index.js:76)
>         in MeetingProvider (at App.js:69)
>         in RCTSafeAreaView (at SafeAreaView.js:51)
>         in SafeAreaView (at App.js:68)
>         in App (at renderApplication.js:47)
>         in RCTView (at View.js:34)
>         in View (at AppContainer.js:107)
>         in RCTView (at View.js:34)
>         in View (at AppContainer.js:134)
>         in AppContainer (at renderApplication.js:40)

如何解决这个问题?

此问题发生在旧版本的SDK中。请更新React原生SDK包以解决此问题。

Npm包:https://www.npmjs.com/package/@videosdk.live react-native-sdk

React原生代码示例:https://github.com/videosdk-live/videosdk-rtc-react-native-sdk-example

相关内容

  • 没有找到相关文章

最新更新