question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React 16.4.1 TS2339: Property 'createContext' does not exist on type 'typeof React'.

See original GitHub issue

Hello 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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
gaearoncommented, Jun 15, 2018

@Rufix

  1. I’m sorry it was useless to you, but as I already explained we literally don’t know the answers, and you’ll get better responses about TypeScript error messages on TypeScript forums.
  2. I closed this after you got a response (thanks @nmain!).
  3. Closing doesn’t stop the discussion in any way. It just removes this from our action list (because this issue is not actionable for us).
6reactions
gaearoncommented, Jun 15, 2018

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found