何时使用类组件,何时使用功能组件 [英] When to use a class component and when to use a functional component

查看:17
本文介绍了何时使用类组件,何时使用功能组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始反应.当我去面试时,他们问我什么时候使用类组件,什么时候使用函数式组件?我不知道这个问题的答案.我知道两者之间的区别二、如何最好地回答这个问题?

I'm new to react.When I go for an interview they ask me When to use a class component and when to use a functional component ?.I do not know the answer to this question.I know the difference between the two.How best to answer this question?

推荐答案

在当前的 post-hooks 时代,答案很简单:你总是使用函数组件.

In current post-hooks era the answer is simple: you always use function components.

这篇关于何时使用类组件,何时使用功能组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆