Я столкнулся с проблемой при отправке ответного объекта выборки с одного экрана на другой с переключателя навигатора (response-navigation v3) - PullRequest
0 голосов
/ 26 сентября 2019
    this is login screen action function from which i am navigating to another screen .

`

  loginAction = () => {
            const newState = !this.state.button_toggle;
            this.setState({ button_toggle: newState });
            const { userName } = this.state;
            const { userPassword } = this.state;
            const { schoolCode } = this.state;
            const { loading } = this.state;
            this.setState({ loading: true });
            fetch('url',
                {
                    method: 'post',
                    header: {
                        'Accept': 'application/json',
                        'Content-type': 'application/json'
                    },
                    body: JSON.stringify({
                        //passing param
                        userName: userName,
                        password: userPassword,
                        schoolCode: schoolCode
                    })
                })
                .then((response) => response.json())
                .then((responseJson) => {
                    alert("response");
                    console.log(responseJson);
                    console.log("=======" + responseJson.studentInfo[0]);
                    console.log("N=" + responseJson.studentInfo[0].studentName);
                    console.log("test-" + responseJson.test[0].A);
                    console.log("test-" + responseJson.test[0].B);
                    console.log("test-" + responseJson.test[0].C);
                    const res = responseJson;
                    if (responseJson.Login == "Success" && responseJson.count == 21) {
                        this.setState({ button_toggle: false });
                    }
                    else if (responseJson.Login == "Success" && responseJson.count == 1) {
                        alert("Login Successful 1");
                        this.props.navigation.navigate('Dashboard', {
                            //myJSON: responseJson.studentInfo[0],
                            myJSON: responseJson,
                            Login: responseJson.Login,
                            studentName: responseJson.studentInfo[0].studentName,
                            studentId: responseJson.studentInfo[0].studentId,
                            studentRollNumber: responseJson.studentInfo[0].studentRollNumber,
                            studentImage: responseJson.studentInfo[0].studentImage,
                            classDescription: responseJson.studentInfo[0].classDescription,
                            studentSection: responseJson.studentInfo[0].studentSection,
                        })
                    } else {
                        alert("Login Failed ");
                    }
                }).catch((error) => {
                    console.log(error);
                    alert(error);
                })
        }

getting the data in next screen like this const Login = this.props.navigation.getParam (" Логин ");const K = this.props.navigation.getParam ("K");const studentName = this.props.navigation.getParam ("studentName");const studentId = this.props.navigation.getParam ("studentId");const studentRollNumber = this.props.navigation.getParam ("studentRollNumber");const classDescription = this.props.navigation.getParam ("classDescription");const studentSection = this.props.navigation.getParam ("studentSection");const classId = this.props.navigation.getParam ("classId");`

это моя навигация

const AppSwitchNavigator = createSwitchNavigator({
  LoginScreen: { screen: LoginForm },
  Dashboard: { screen: AppDrawerNavigator }
});

внутри навигатора стека он работает, но во внутреннем навигаторе коммутатора он не работает

...