C
C
Capablanca2019-04-23 18:57:49
typescript
Capablanca, 2019-04-23 18:57:49

Fix TS typing error?

Deployed create-react-app with TS
There is a book prop that falls into components via typing book= BookParamsTypes[];
I don't transmit or use any more props.

export type BookParamsTypes = {
  title: string;
  pubDate?: number;
};

in App.tsx I make a call to the component, I pass it a mock book={IOC} - that is, an array of objects.
This accepts an element and should be used internally. But it's already a mistake.
"JSX element type '{ book: BookParamsTypes[]; (Missing): any; }' is not a constructor function for JSX elements.
  Type '{ book: BookParamsTypes[]; (Missing): any; }' is missing the following properties from type 'Element': type, props, keyts(2605)"

(Missing): any ? - what it needs
. The receiving element inside should output a div through the map for each object in the array.
for example
{book.map((item: any, i: number) => (
    <Container key={i}>
      <BookTitle>{item.title}</BookTitle>
       // и так далее
      }
    </Container>
  ))}

Here he offers me to put a comma instead of a dot before the map and that's it ...
Apparently the main problem is in the text of the error above, I can't cope with this hint ..
Please help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question