小编HSB*_*SBP的帖子

如何关闭原生态的模态

我是新手,以反应原生发展.我想在反应中按下模态外部关闭模态组件.以下是我的代码.

state = {
    visibleModal : false,
};

_hideModal(){
  this.setState({
    visibleModal: true,
  })
}


render(){
    return(
        <View style={
            [styles.container,
                {backgroundColor: this.state.visibleModal ? 'rgba(47, 60, 73, 0.75)': 'white'}
            ]}>

            <Text>Text Behind Modal</Text>

            { this._renderButton('BUTTON', () => this.setState({ visibleModal: true}) ) }
            <TouchableWithoutFeedback onPress={() => {this._hideModal()}}>
            <Modal animationType={"slide"}
                   transparent={true}
                   visible={this.state.visibleModal}>

                      <View style={styles.modalContent}>
                          <Row />
                      </View>

            </Modal>
          </TouchableWithoutFeedback>
        </View>
    );
}
Run Code Online (Sandbox Code Playgroud)

}

reactjs react-native react-redux

8
推荐指数
1
解决办法
2万
查看次数

如何使用 react-native-fs 库访问文件和文件夹

我正在使用 react-native-fs 进行文件系统访问。但是我无法访问ios中的文件。

下面是代码:

RNFS.readDir(RNFS.MainBundlePath)
.then((result) => {
    console.log('Got result', result);
    return Promise.all([RNFS.stat(result[0].path), result[0].path]);
})
    .then((statResult) => {
        console.log('stat result',statResult);
        if(statResult[0].isFile()){
            return RNFS.readFile(statResult[1], 'utf8');
        }
        return 'no file';
    })
        .then((contents) => {
            console.log('Got Contents',contents);
        })
.catch((err) => {
    console.log(err.message, err.code);
})
Run Code Online (Sandbox Code Playgroud)

我正在获取 MainBundlePath 的路径文件,但没有获取本地存储的任何其他文件/文件夹。

react-native react-native-fs

1
推荐指数
1
解决办法
2万
查看次数