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.

useState is not defined

See original GitHub issue

Running into an error trying to use the hooks api with react-live. currently i get useState is not defined display as an error. I had a demo of it in codesandbox that i’ll link to below. I ran into the issue trying to add it to a next.js application but the code-sandbox is using create-react-app as i wasn’t sure if it might’ve, could’ve ben a ssr thing. i’m not sure if updating react might be the solution but that’d be great if so 😄

codesandbox demo

Screenshot of error in demo

screen shot 2019-02-18 at 5 48 41 am

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

58reactions
kittencommented, Feb 18, 2019

Actually, if you use a react version that’s new enough you just have to use React.useState. Like with React.Component react-live only exposes React in its context, but nothing else by default.

You can obviously pass in more yourself but by default you’ll only have the complete React variable 😃

1reaction
tgrecojscommented, Feb 19, 2019

Awesome! Thanks so much for getting back to me so quickly @kitten … you rock 💪

Read more comments on GitHub >

github_iconTop Results From Across the Web

'useState' is not defined no-undef React - Stack Overflow
I'm trying to use react hooks for a simple problem. I believe the solution is stupid but I don't see it. I Tried...
Read more >
useState is not defined - JavaScript - The freeCodeCamp Forum
useState is not defined · Most basically, store that state in a component that is an ancestor to both child components. Passing the...
Read more >
Why are the useState values not defined? : r/react - Reddit
I have a react application. I recently added a POST feature. When I connected it to the front end via useContext, I got...
Read more >
usestate is not defined - Code Examples & Solutions For This ...
import React, {useState} from 'react'; ... usestate is not defined. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On...
Read more >
[Solved]-'useState' is not defined no-undef React-Reactjs
[Solved]-'useState' is not defined no-undef React-Reactjs · score:80. Accepted answer. You need to import "useState": · score:7. You have forgotten to import ...
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