React 16.4.1 TS2339: Property 'createContext' does not exist on type 'typeof React'.
See original GitHub issueHello there,
Kinda new to React, trying to delve a bit into Contexts, however the aforementioned method refuses to exist.
import * as React from "react";
export const UrlEditContext = React.createContext(new UrlViewItem());
This is really all the code I’ve got on this. This happens both with React 16.4.1 and 16.3.2. Other React libraries I have:
react-dom 16.0.0 react-hot-loader 3.0.0-beta.7 (came with the project created with Visual Studio) react-router-dom 4.1.1
Typescript’s version’s 2.4.1.
Anyone has any idea why would I receive the aforementioned error? Google and SO have literally (yes, literally) nothing on the topic.
Thanks, Huggy
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
TypeScript and createContext - Property is missing on type
In the UserContext.Provider , the value is expecting a type of { id: undefined } but you are currently assigning the value to...
Read more >property 'createroot' does not exist on type 'typeof import
I can't use createRoot function in react-dom/client ... bash error TS2339: Property 'utime' does not exist on type 'typeof Deno'. await Deno.utime(dest, ...
Read more >Working with React Context in TypeScript
NOTE: This blog post assumes that you are already familiar with writing types and interfaces in TypeScript, as well as the basics of...
Read more >Context | React TypeScript Cheatsheets
This is a quick and easy fix, but this loses type-safety, and if you forget to supply a value to the Provider, you...
Read more >How do I add types for React's useContext? : r/typescript - Reddit
Try typing the createContext with AppState instead of the hook. useContext will automatically pick up the correct states for it.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Rufix
As to why I’m closing this—we’re using the issue tracker for bug reports and feature requests in React. This is neither. We try to respond to questions when we can, but in this case we’re not the right people to answer your question.
We maintain a list of community resources. Some of these might have other TypeScript users, so check them out: https://reactjs.org/community/support.html
Hope it helps!