Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Cannot find namespace 'React'. #213

Open
donaldpipowitch opened this issue Jan 10, 2018 · 4 comments
Open

Cannot find namespace 'React'. #213

donaldpipowitch opened this issue Jan 10, 2018 · 4 comments

Comments

@donaldpipowitch
Copy link

Error happens because of this line: https://github.com/react-ga/react-ga/blob/master/types/index.d.ts#L74.

I think you must add @types/react as a (peer or normal) dependency and than add import * as React from 'react'; or so to your index.d.ts.

@SimeonC
Copy link
Contributor

SimeonC commented Jan 13, 2018

Can you do a PR for this? I don't actively use TS so I rely on PR's for this.

@doronnac
Copy link

doronnac commented Feb 7, 2018

I believe this involves either generating declaration file programmatically to incorporate needed React types, which requires some setup changes, or setting @types/react as a peerDependency, which is bad for non-typescript users.
Maybe a good first step is to add a typescript section to the getting started docs and specifying that npm i @types/react is required

@sgruse
Copy link

sgruse commented May 2, 2018

I see that this line has been added:

import * as React from 'react';

I can see this in the master branch at /types/index.d.ts but when I download the module I don't see this change. Can you please draft a new release with this change. I'm trying to use this in a Typescript React application. Thanks a lo!

@JusticeBringer
Copy link

JusticeBringer commented Apr 1, 2021

npm install @types/react worked for me. Thanks @donaldpipowitch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants