componentDidMount() { this.invoke.define('onLogout', this.onLogout) }
render() { const { token } = this.props return ( <SafeAreaView style={{ flex: 1, backgroundColor: '#fff' }}> <WebView useWebKit ref={webview => (this.webview = webview)} onMessage={this.invoke.listener} source={{ uri: `${REACT_APP}/?token=${token}`, }} bounces={false} /> </SafeAreaView> ) }
const logout = async dispatch => { try { const onLogout = invoke.bind('onLogout') if (onLogout) { onLogout().then(() => {}) } await axios.delete(`${BASE_URL}/user/logout`) await dispatch({ type: 'LOGOUT' }) window.localStorage.removeItem('token') setAuthToken(false) history.push('/') } catch (err) { console.log(err) } }