javascript - 混淆了默认和命名导入?
问题描述
在我的 Firebase Cloud Firestore 中显示数据,但在我的代码中出现错误。无法理解问题是什么?
我尝试在新文件中使用导出默认值,而不是为我的 RootStack 使用类,但是当我尝试这样做时也出现错误。
export default class App extends React.Component {
render() {
return <RootStack />;
}
}
const RootStack = createStackNavigator(
{
Auth: {
screen: Auth, navigationOptions: { header: null },
},
Login: {
screen: Login, navigationOptions: { header: null },
},
Home: {
screen: Home, navigationOptions: { header: null },
},
}
);
class Home extends React.Component {
constructor(props){
super(props);
this.state = ({
todoTasks: []
})
this.ref = firestore.collection("tips");
}
componentDidMount() {
this.unsubscribe = this.ref.onSnapshot((querySnapshot) => {
const todos = [];
querySnapshot.forEach((doc) => {
todos.push({
tips: doc.data().tips
})
})
this.setState({
todoTask: todos
})
})
}
render() {
return (
<View>
<Flatlist
data={this.state.todoTask}
renderItem={({ item, index }) => {
return(
<Text>{item.tips}</Text>)
}}
>
</Flatlist>
</View>
)
}
}
解决方案
推荐阅读
- javascript - 当我使用 Angularjs 的 ng-repeat 时,我需要防止对特定“类”的迭代。有人能帮我吗?
- html - HTML CSS 位置 div 左 中 右
- c++ - 如何从现有的 VS2019 (.exe) 项目为 android (Xamarin) 构建 .so 文件?
- javascript - 使用聚合查询出现错误,“字段名称 '$acknowledged' 不能是运算符名称”
- spring - 回滚场景的 RestCall 事务问题
- c++ - 我可以在 std::find_if 的并行版本中使用不可复制的迭代器吗?
- reactjs - 如何在样式组件中同时使用 (max-device-width) 和 (min-device-width)?
- php - cURL 错误 2:简单句柄已用于多句柄(参见 http://curl.haxx.se/libcurl/c/libcurl-errors.html)Google 客户端访问令牌
- javascript - 传单使用 setInterval 删除重复标记
- javascript - UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT] - setInterval & Axios.post 错误处理