RN Project에 Redux를 통합했습니다. 나는 버튼과 화면 사이를 탐색 할 수 있습니다,하지만 난 HeaderBackButton으로 돌아 가야 할 때를 말한다 :Redux를 사용하여 네이티브 핸들 백 헤드백에 응답
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;
이것은 작동하지 않으며 같은 문제가 발생합니다 : "정의되지 않은 것은 객체가 아닙니다" –
디버거를 사용하여 테스트 해 보겠습니다. 문제가 해결되기를 바랍니다. 하지만 당신의 대답을 주셔서 감사합니다 :) –