1
バックボタンを押すと、前の画面に戻りますが、アプリも閉じます。私はすでにevent.preventDefault()を追加しようとしましたが、私の問題は修正されません。BackAndroid - アプリがまだ閉じています
componentWillMount() {
BackAndroid.addEventListener('hardwareBackPress',() => {
this.goBack();
})
}
goBack() {
this.props.actions.goBack();
}
//Reducer
export default function navReducer(state = initialState, action = {}) {
switch(action.type) {
case types.OPEN:
return {
scenes: [
...state.scenes,
{key: action.key, name: action.name}
]
};
case types.BACK:
if(state.scenes.length > 1) {
return {
scenes: state.scenes.slice(0, state.scenes.length - 1)
}
} else {
console.log('Error')
};
default:
return state;
}
}