Search code examples
javascriptreactjstypescriptnpmreact-modal

Can't import typescript react-modal


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


Solution

  • You have to import it as:

    import * as ReactModal from 'react-modal';