在模型内部未显示React Native Router Flux屏幕

时间:2019-06-20 11:47:45

标签: react-native react-router react-navigation react-native-router-flux

我在Text tap中打开了模型。模型已正确打开,但是在模型内部,还有一个导航按钮已经打开了表单。按钮没有打开表单。

“调用模型:”

renderClientName(){
    return(
        <View style={{marginTop:10,backgroundColor:'#ffffff'}}>
            <Text style={styles.textStyle}>Client Name</Text>
            <TouchableOpacity onPress={()=>{
                this.setState({showClientModal:true})
            }}
                    disabled={this.isTouchDisabled()}>
                <Text style={[styles.textStyle,styles.borderStyle,this.getClientBorderColor(),
                {color: (this.state.clientName === "Client Name # (mandatory)") ? '#c6c6bb' : '#000'}]}>
                    {this.state.clientName}
                </Text>
            </TouchableOpacity>
            {this.renderErrorText('CN')}
        </View>
    );
}

“渲染模型:”

    renderClientModal() {
    return(
        <Modal visible={this.state.showClientModal}
            //onRequestClose={() => { }}
            onRequestClose={() => this.setState({ showClientModal: false })}
            animationType="slide">
            <ClientScreen all_clients = {get_all_clients()} 
                onBack={()=>{this.setState({showClientModal:false})}} 
                onAddClient={this.addClientScreen.bind(this)} 
                onPressClient={this.closeModal.bind(this)} 
                selectClient state={this.baseState}
                addClient={true} />
        </Modal>
    )
}

“客户端屏幕”:     返回(             

            screen={Screen} 
            title={'Client'} 
            imageLeft={menuImage}
            // showHomeIcon={true}
            // onHomePress={()=>{Actions.pop()}}
            showBackIcon={true}
            onBackPress={()=>{Actions.pop()}}
            showAddIcon = {true}

            onLeftHeaderPress = {() => {Keyboard.dismiss(), this.state.Navigation.navigate('DrawerOpen'); } }
            onAddPress ={() => { 
                >>Actions.AddClient()
                // Actions.pop()
                // this.routeToAddMeetingScreenForm()
                // Keyboard.dismiss()
                // if(applicationProperties.FirstSync === "true") {
                // }
                // else if(applicationProperties.FirstSync === "false"){
                //     this.setState({loading:false})
                //     Alert.alert(
                //         "Error",
                //         "Your first sync was unsuccessfull, please sync to add client",
                //         [
                //         {text: 'OK', onPress: () => console.log('OK Pressed')},
                //         ],
                //         { cancelable: true }
                //     )
                // }
             } }
            // showBackIcon={true}
            // onBackPress={()=>{Actions.pop()}}
    />
    )
}

最后一个代码具有指向Actions.AddClient()的onAddPress路由,该路由不起作用。

1 个答案:

答案 0 :(得分:0)

我已经通过自己的研究解决了问题。我在componentWillReceiveProps中调用了setState方法,因此在注释掉该方法后可以正常工作。