React: useState and useEffect are undefined

Created on 30 Oct 2018  路  2Comments  路  Source: facebook/react

Do you want to request a feature or report a bug?
Report a "bug"

What is the current behavior?
I have a upgraded react to v16.6.0 in order to be able to use the new hooks method. I'm importing useState and useEffect from react but the browser keeps saying that useState and useEffect are undefined. So I decided to log react on the browser to check if the version was correct and if the 2 methods were there.

This is what I found out:
screenshot from 2018-10-30 13-04-13

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
All I did is upgrading (yarn upgrade react@latest react-dom@latest) and use the normal import
import React, { useState, useEffect } from 'react'

What is the expected behavior?
I would expect the two functions above to be defined.
Do you know if I did anything wrong, or what could have possibly gone wrong?

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React: v16.6.0
Browser: Chrome Version 70.0.3538.77 (Official Build) (64-bit)
OS: ubuntu 18.10

Most helpful comment

hooks are still in RFC and only available in alpha builds.

https://reactjs.org/docs/hooks-overview.html
screen shot 2018-10-30 at 9 16 00 am

Try something like: yarn upgrade [email protected] [email protected]

All 2 comments

hooks are still in RFC and only available in alpha builds.

https://reactjs.org/docs/hooks-overview.html
screen shot 2018-10-30 at 9 16 00 am

Try something like: yarn upgrade [email protected] [email protected]

My bad!! I should have noticed it was still a proposal! Sorry about that!

Was this page helpful?
0 / 5 - 0 ratings