Skip to content

euZebe/naive-implementation-of-react-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

naive-implementation-of-react-hooks

A way to understand why react hooks can be conditional

steps

  • starting from "initial" tag
  • remove useState import, create a useState local function
  • add a console.log in the setter => new value set, but nothing visible
  • force rerender (ok, this is a hack)
  • add states cache
  • handle state exists in the cache
  • in setValue, update value from the statesCache

=> useState can't be called conditionally

About

A way to understand why react hooks can be conditional

Resources

License

Stars

Watchers

Forks

Packages

No packages published