混淆了默认输入和命名输入?

时间:2018-07-29 16:53:48

标签: javascript firebase react-native google-cloud-firestore

正在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>
            )
        }
    }

enter image description here

0 个答案:

没有答案