React: useState or useRef?

后端 未结 2 1151
不思量自难忘°
不思量自难忘° 2020-12-23 16:12

I am reading about React useState() and useRef() at \"Hooks FAQ\" and I got confused about some of the use cases that seems to have solution with

2条回答
  •  [愿得一人]
    2020-12-23 16:52

    Basically, We use UseState in those cases, in which the value of state should be updated with re-rendering.

    when you want your information persists for the lifetime of the component you will go with UseRef because it's just not for work with re-rendering.

提交回复
热议问题