Programing

기본 반응 - NavigationActions.navigate()가 Redex 내에서 탐색하지 않음

c10106 2022. 3. 10. 22:09
반응형

기본 반응 - 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서랍장 스택이 아니라.탐색 구성 요소가 아닌 특정 화면으로 이동하십시오.

참조URL: https://stackoverflow.com/questions/49406014/react-native-navigationactions-navigate-not-navigating-from-within-redux

반응형