0

我试图使用react-native-instagram-login将 instagram 登录集成到我的应用程序中,它当前抛出错误,我已经完成了以下更改以使其工作还尝试遵循链接中的特定解决方案,但似乎没有工作,任何帮助将不胜感激

 ERROR  Invariant Violation: View config getter callback for component `RCTModalHostView` must be a function (received `undefined`).

This error is located at:
in RCTModalHostView (at Modal.js:258)
in Modal (at Instagram.js:119)
in Test(at Instagram.js:44)
in RCTView (at View.js:34)
in View (at Instagram.js:25)
in Test(at SceneView.tsx:122)
...
ERROR  Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in WebView (at Instagram.js:99)
in RCTView (at Instagram.js:126)
in RCTView (at Instagram.js:125)
in RCTView (at AppContainer.js:101)
in RCTView (at AppContainer.js:119)
in AppContainer (at Modal.js:250)
in RCTView (at Modal.js:271)
in RCTModalHostView (at Modal.js:258)
in Modal (at Instagram.js:119)
in Test(at Instagram.js:44)
in RCTView (at View.js:34)
in View (at Instagram.js:25)
in Test(at SceneView.tsx:122)
...

包.json

{
 "name": "ui",
 "version": "0.0.1",
 "private": true,
 "scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
 },
"dependencies": {
"@react-native-async-storage/async-storage": "^1.15.5",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-cookies/cookies": "^6.0.8",
"@react-navigation/drawer": "^5.12.5",
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.5",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-animatable": "^1.3.3",
"react-native-calendars": "^1.1264.0",
"react-native-dropdown-autocomplete-textinput": "^1.0.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-image-crop-picker": "^0.36.2",
"react-native-instagram-login": "^2.0.4",
"react-native-linear-gradient": "^2.5.6",
"react-native-modal-datetime-picker": "^10.0.0",
"react-native-paper": "^4.9.2",
"react-native-reanimated": "^2.2.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.4.0",
"react-native-searchable-dropdown": "^1.1.3",
"react-native-vector-icons": "^8.1.0",
"react-native-webview": "^11.6.5",
"toggle-switch-react-native": "^3.2.0"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/runtime": "^7.14.6",
"@react-native-community/eslint-config": "^3.0.0",
"babel-jest": "^27.0.5",
"eslint": "^7.29.0",
"jest": "^27.0.5",
"metro-react-native-babel-preset": "^0.66.0",
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
 }
 }

测试.js

  ...
  const Test= ({navigation}) =>{
  const[token,setToken]=useState('');
  setIgToken = (data) => {
    console.log('data', data)
    this.setToken({ token: data.access_token })
  };

  return(
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    <TouchableOpacity
      style={styles.btn}
      onPress={() => this.instagramLogin.show()}>
      <Text style={{ color: 'white', textAlign: 'center' }}>Login now</Text>
    </TouchableOpacity>
    <TouchableOpacity
      style={[styles.btn, { marginTop: 10, backgroundColor: 'green' }]}
      onPress={() => clear()}>
      <Text style={{ color: 'white', textAlign: 'center' }}>Logout</Text>
    </TouchableOpacity>
    <Text style={{ margin: 10 }}>Token: {token}</Text>
   
    <InstagramLogin
      ref={ref => (this.instagramLogin = ref)}
      appId='appId'
      appSecret='appSecret'
      redirectUrl='redirectUrl'
      scopes={['publish_video',    'pages_show_list','instagram_basic','instagram_content_publish','pages_read_engagement']}
      onLoginSuccess={this.setIgToken}
      onLoginFailure={(data) => console.log(data)}
    />
  </View>
 );
 };
4

1 回答 1

0

我有一个 2 部分的问题。

  1. 多个反应 webview 是一个问题,因此请删除 instagram 中的一个登录跟随 stackoverflow.com/a/67917642/8704042
  2. 由于我的模拟器无法访问互联网,因此面临连接问题。在我的情况下,原来是我的开发环境(Windows 操作系统)已损坏,修复它开始工作(操作系统重新格式化对我有用)。但是我看到其他人通过 vpn 设置修复了它,也检查一下,在我的情况下,我一直收到类似“ERR .....无法获取 IP”的错误
于 2021-07-10T18:47:35.563 回答