【发布时间】:2019-05-09 08:11:57
【问题描述】:
这一行: var a = require('react-native-fs');
返回以下错误: JSX 值应该是表达式或引用的 JSX 文本(53:22)
感谢您的帮助。
import React from 'react';
import {
StyleSheet,
View,
Text,
TextInput,
} from 'react-native';
export default class Component1 extends React.Component {
constructor(props) {
super(props);
this.state = {
textInputValue: "",
}
}
render() {
if (!this.props.visible) {
return false;
}
return (
<View
style={styles.component}
>
<View style={styles.layouts}>
<View style={styles.layout1}>
<View style={styles.itemcontainer1}>
<View style={styles.itemcontainer1Inner}>
<View style={styles.item1}>
<TextInput
style={styles.item1TextInput}
placeholder={"b"}
underlineColorAndroid={"transparent"}
placeholderTextColor={"rgba(0,0,0,1)"}
onChangeText={(val) => this.setState({ textInputValue: val })}
value={this.state.textInputValue}
var a = require"react-native-fs";
var path = a.DocumentDirectoryPath + '../textfile.txt';
a.writeFile(path, this.state.textInputValue, 'utf8');
.then((success) => {
console.log('File Written');
【问题讨论】:
-
除非该行以某种方式嵌入到 JSX 表达式中,否则它不是错误的原因。你能告诉我们更多吗?
-
你这是什么意思?我是编程新手。
-
您向我们展示的代码不是问题所在。为了帮助您,我们需要查看更多代码。错误表明问题出在第 53 行,因此请向我们展示该行 及其周围的代码。
-
我编辑了问题以包含周围的代码。
-
谢谢,有足够的信息来回答这个问题。我很快就会发布一个。
标签: javascript reactjs expo fs