我正在为iOS编写一个React Native应用,我将使用AWS Amplify处理身份验证。
如here所述,我将组件包装如下,
from matplotlib import pyplot as plt
import numpy as np
def show_values_on_bars(axs):
def _show_on_single_plot(ax):
for p in ax.patches:
_x = p.get_x() + p.get_width() / 2
_y = p.get_y() + p.get_height()
value = '{:.2f}'.format(p.get_height())
ax.text(_x, _y, value, ha="center")
if isinstance(axs, np.ndarray):
for idx, ax in np.ndenumerate(axs):
_show_on_single_plot(ax)
else:
_show_on_single_plot(axs)
fig, ax = plt.subplots(1, 2)
show_values_on_bars(ax)
在这里,我用import React, { Component } from 'react';
import { View, StatusBar } from 'react-native';
import { connect } from 'react-redux';
import { withAuthenticator } from 'aws-amplify-react-native';
import { addNavigationHelpers } from 'react-navigation';
import ReduxNavigation from '../Navigation/ReduxNavigation';
// Styles
import styles from './Styles/RootContainerStyles';
import LaunchScreen from './LaunchScreen';
class RootContainer extends Component {
render() {
return (
<View style={styles.applicationView}>
<StatusBar barStyle="light-content" />
<ReduxNavigation />
</View>
);
}
}
const mapStateToProps = state => ({
});
// wraps dispatch to create nicer functions to call within our component
const mapDispatchToProps = dispatch => ({
dispatch
// startup: () => dispatch()
});
export default connect(mapStateToProps, mapDispatchToProps)(
withAuthenticator(RootContainer, false, [
<LaunchScreen navigation={addNavigationHelpers()} />
])
);
包裹了RootContainer
并添加了withAuthenticator
作为身份验证器组件。
但是在LaunchScreen
内部,我将处理路由事件,因为,
LaunchScreen
,但此操作无效,并抛出错误,
this.props.navigation.navigate('PasswordReset');
我使用Ignite来生成应用程序结构。
请帮助解决这个问题,我已经尝试了许多不同的方法。