Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

javascript - 您何时在反应中使用类组件,因为useState现在在功能组件中可用(When do you use class components in react since useState is now available in Functional components)

I am not an expert in react so I am a little confused but since the introduction of react hooks.

(我不是React方面的专家,所以我有点困惑,但是由于引入了react hooks。)

when do you use class components instead of functional components?

(什么时候使用类组件而不是功能组件?)

  ask by Inioluwa Sogelola translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I would use class when there is something that functional components can't implement like state or lifecycle methods, waitttttttttttttttttt...

(当功能组件无法实现的某些东西(例如状态或生命周期方法),waitttttttttttttttttttttt时,我将使用类...)

Since hooks have the state and lifecycle methods you don't need classes anymore :)

(由于钩子具有状态和生命周期方法,因此您不再需要类 :))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...