为什么constructor中必须含有“super”调用?

来源:3-9 【组件化】创建class类组件

Zhang_Kyra

2021-06-20

老师您好,为什么constructor中必须含有“super”调用?
constructor(props: Props) {
super(props);
this.state =
{
isOpen: false,
};
}

constructors for derived classes must contain a ‘super’ call.

写回答

1回答

阿莱克斯刘

2021-06-22

hello 同学,你的问题我们可以在react的官方文档中找到答案:https://zh-hans.reactjs.org/docs/react-component.html#constructor

//img.mukewang.com/szimg/60d0d6fa0933570019041430.jpg

0
0

React18 系统精讲 结合TS打造旅游电商平台

React18 精讲 + 结合 TS 实战 + 热门业务开发,获取必备技能

1993 学习 · 1015 问题

查看课程