3

I'm starting from an open source project here:

https://github.com/vega/voyager

And got it working and I want to add a modal.

So I ran:

yarn add react-modal
yarn add @types/react-modal

Then I added added:

import {ReactModal} from 'react-modal';

I'm getting this on the build ERROR in ./src/components/header/chrono-history.tsx (5,9): error TS2305: Module '"/Users/brennanwallace/psa/voyager/node_modules/@types/react-modal/index"' has no exported member 'ReactModal'.

And web-storm agrees that there is an issue as it gives the same error in text editing viewport.

What can I do?

I'm new to type script but the files seem in order:

There is a react-modal folder in @types in node_modules with index.d.ts like several other moduals (it is missing a types-metadata.json file which the other packages seem to have).

There is also a react-modal package.

The tsconfig.json files also seems in order: https://github.com/vega/voyager/blob/vy2/tsconfig.json

Bren
  • 3,516
  • 11
  • 41
  • 73

1 Answers1

5

You have to import it as:

import * as ReactModal from 'react-modal';
Saravana
  • 37,852
  • 18
  • 100
  • 108
  • i did excatly this, but it didnt help. Still getting the error `React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of ...` – Paulquappe Aug 08 '17 at 07:37