在Expo Go中使用AWS Amplify Auth.SignOut会引起崩溃的问题,解决方法是使用unmountComponentAtNode将应用程序适当地卸载。
解决方法代码示例:
import React from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; import Amplify, { Auth } from 'aws-amplify';
Amplify.configure({ Auth: { region: 'your-region', userPoolId: 'your-user-pool-id', userPoolWebClientId: 'your-client-id', }, });
const App = () => { const handleSignOut = async () => { try { await Auth.signOut(); } catch (error) { console.log('Error signing out: ', error); }
// 在此卸载应用程序
const rootNode = document.getElementById('root');
ReactDOM.unmountComponentAtNode(rootNode);
};
return (
export default App;