RNプロジェクトにReduxを統合しました。私はボタンで画面間を移動することができますが、私はHeaderBackButtonに戻りたいとき、それは言う:「未定義の関数ではありません」Native Handle Headerback with Reux
のGithub-レポ:https://github.com/bayraktarhasan/React-Navigation-Redux-Globalization-Example.git
マイフィードコンポーネント:
class Feed extends Component {
static navigationOptions = {
title: 'Hello Ahmet',
headerLeft: <HeaderBackButton onPress={this.goBack()} />,
}
constructor(props) {
super(props);
this.goBack = this.goBack.bind(this);
}
goBack =() => {
this.props.navBack();
}
render() {
return (
<View style={styles.container}>
<Text>{I18n.t('feedComponent')}</Text>
<Button
title={I18n.t('back')}
onPress={this.goBack}
/>
</View>
);
}
}
export default connect(null, { navBack, navToProfile })(Feed);
リデューサー:
import { NAVIGATE_BACK, NAVIGATE_PROFILE, NAVIGATE_FEED } from '../Actions/types';
const firstAction = AppNavigator.router.getActionForPathAndParams('Main');
const initialNavState = AppNavigator.router.getStateForAction(
firstAction
);
function nav(state = initialNavState, action) {
console.log(action.type);
let nextState;
switch (action.type) {
case NAVIGATE_BACK:
nextState = AppNavigator.router.getStateForAction(
NavigationActions.back(),
state
);
break;
これは機能しません。同じ問題が発生します。「未定義はオブジェクトではありません」 –
私はデバッガでテストするつもりです。修正することを願っています。しかし、あなたの答えをありがとう:) –