0

当我尝试导入 reduxcompose组件时,我遇到了一个奇怪的导入错误,我不知道是什么原因造成的,我已经@types为所涉及的软件包安装了所有最新的:

错误:

JSX element type 'PostTable' does not have any construct or call signatures.

家长

import React from 'react';
import { Container, Row, Col } from 'react-bootstrap';
import CreatePost from '../postings/CreatePost';
import PostTable from '../postings/PostTable';

export default (props: { [key: string]: any }) => {
  return (
    <Container>
      <Row>
        <Col>
          <CreatePost></CreatePost>
        </Col>
        <Col>
          <PostTable></PostTable> //Error occurs here
        </Col>
      </Row>
    </Container>
  );
};

孩子

import React from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { firestoreConnect } from 'react-redux-firebase';

const PostTable = (props: { [key: string]: any }) => {
  return (
    <table className="table table-striped">
      <thead>
        <tr>
          <th scope="col">#</th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
        </tr>
      </thead>
      <tbody>
        {props.posts.map((post: { [key: string]: any }) => {
          return (
            <tr>
              <th scope="row">{post.id}</th>
              <td>{post.title}</td>
              <td>{post.content}</td>
            </tr>
          );
        })}
      </tbody>
    </table>
  );
};

const mapStateToProps = (state: { [key: string]: any }) => {
  return {
    posts: state.firestore.ordered.posts,
  };
};

export default compose(
  connect(mapStateToProps),
  firestoreConnect([
    {
      collection: 'posts',
    },
  ])
)(PostTable);

4

0 回答 0