반응형
기본 반응 - NavigationActions.navigate()가 Redex 내에서 탐색하지 않음
두 명의 네비게이터가 있는데 하나는 스택내비게이터고 다른 하나는 드로어내비게이터야.내가 원하는 것은 액션을 발송하고 로그인이 성공하여 사용자를 드로어 네비게이터로 리디렉션하는 것이다.나는 리액션 네비게이션을 사용해 왔다.내가 한 일은 액션 로그인 성공작품을 사연에 보낸 것이다.사용.NavigationActions.navigate({ routeName: 'drawerStack' })
출동시키다동작은 성공적으로 전송되지만 아래 그림과 같이 드로어내비게이터로 이동하지 않는다.내가 뭘 잘못하고 있는 거지?
사가.js.
function* watchLoginRequest() {
while (true) {
const { state } = yield take(LOGIN_REQUEST);
try {
const payload = {
state
};
const response = yield call(loginCall, payload);
yield put(loginSuccess(response));
yield setUser(response.user);
yield put(NavigationActions.navigate({ routeName: 'drawerStack' }));
} catch (err) {
yield put(loginFailure(err.status));
}
}
}
서랍내비게이션js
// drawer stack
const DrawerStack = DrawerNavigator({
testComponent: { screen: TestComponent },
});
const DrawerNav = StackNavigator({
drawerStack: { screen: DrawerStack }
}, {
headerMode: 'float',
navigationOptions: ({ navigation }) => ({
headerStyle: { backgroundColor: 'green' },
title: 'Logged In to your app!',
headerLeft: <Text onPress={() => navigation.navigate('DrawerOpen')}>Menu</Text>
})
});
export default DrawerNav;
로그인내비게이션.js
// login stack
const LoginStack = StackNavigator({
startScreen: { screen: StartScreen },
loginScreen: { screen: LoginScreen },
personalInformation: { screen: PersonalInformation },
vehicleInformation: { screen: VehicleInformation },
availability: { screen: Availability },
selectRegisteration: { screen: SelectRegisteration },
serviceAddress: { screen: ServiceAddress },
}, {
headerMode: 'none',
transitionConfig: TransitionConfiguration
});
export default LoginStack;
ReducxNavigation.js
class ReduxNavigation extends React.Component {
constructor(props) {
super(props);
const { dispatch, nav } = props;
const navigation = ReactNavigation.addNavigationHelpers({
dispatch,
state: nav
});
this.state = {
loggedInStatus: false,
checkedSignIn: false
};
}
componentWillMount() {
isSignedIn()
.then(res => {
if (res !== null) {
this.setState({
loggedInStatus: true,
checkedSignIn: true
});
} else {
console.log(res);
}
})
.catch(err => console.log(err));
}
render() {
return <LoginNavigation navigation={this.navigation} />;
}
}
const mapStateToProps = state => ({ nav: state.nav });
export default connect(mapStateToProps)(ReduxNavigation);
로 이동하려면 다음과 같이 하십시오.TestComponent
당신은 당신의 것을 원한다.routeName
되려고testComponent
서랍장 스택이 아니라.탐색 구성 요소가 아닌 특정 화면으로 이동하십시오.
반응형
'Programing' 카테고리의 다른 글
참조에 이벤트 수신기를 추가하는 방법 (0) | 2022.03.11 |
---|---|
첫 번째 http 요청이 완료되었을 때만 새 http 요청을 실행하고 중간에 다른 모든 요청을 무시/취소하는 방법 (0) | 2022.03.11 |
Python에서 '이넘'을 어떻게 대표할 수 있을까? (0) | 2022.03.10 |
Vue2에서 디바운스를 구현하는 방법? (0) | 2022.03.10 |
레일 레이아웃을 사용하여 다른 반응 구성 요소에서 반응 구성 요소 렌더링 (0) | 2022.03.10 |