0

我将参数从屏幕 A 传递到屏幕 B

屏幕 A:

<Button
          title="Go Next"
          onPress={() =>
            navigate('liveScreen', {
              linkItem: this.state.link,
            })
          }
        />

屏幕 B:

import React, { useEffect } from 'react';
import JitsiMeet, { JitsiMeetView } from 'react-native-jitsi-meet';

function linkScreen() {

  useEffect(() => {
    setTimeout(() => {
      const url = `https://meet.jit.si/${this.props.navigation.state.params.linkItem}`;
      const userInfo = {
        displayName: 'User',
        email: 'user@example.com',
        avatar: 'https:/gravatar.com/avatar/abc123',
      };
      JitsiMeet.call(url, userInfo);
    }, 1000);
  }, [])

  useEffect(() => {
    return () => {
      JitsiMeet.endCall();
    };
  });

  function onConferenceTerminated(nativeEvent) {
    console.log(nativeEvent)
  }

  function onConferenceJoined(nativeEvent) {
    console.log(nativeEvent)
  }

  function onConferenceWillJoin(nativeEvent) {
    console.log(nativeEvent)
  }
  return (
    <JitsiMeetView
      onConferenceTerminated={e => onConferenceTerminated(e)}
      onConferenceJoined={e => onConferenceJoined(e)}
      onConferenceWillJoin={e => onConferenceWillJoin(e)}
      style={{
        flex: 1,
        height: '100%',
        width: '100%',
      }}
    />
  )
}
export default linkScreen;

但屏幕 B 上显示“未定义不是对象(正在评估 '_this.props.navigation')”的错误

我使用 react-native-jitst-meet 为班级项目创建简单的会议应用程序。真心希望各位大神给个解决办法。之前谢谢你

4

1 回答 1

0

您正在使用功能组件。所以你不能作为 this.props.navigation 访问它

首先,您必须添加如下道具

function linkScreen({navigation}) {

然后你可以像下面一样访问它

const url = `https://meet.jit.si/${navigation.state.params.linkItem}`;
于 2020-10-31T10:52:59.003 回答