老师为什么泛型languageState用逗号,WithTranslation却用&呢

来源:8-7 【i18n】完成网站语言切换

你不懂我胖虎

2021-01-19

写回答

2回答

阿莱克斯刘

2021-01-20

  • React.Component的范型接受两个参数,

React.Component<Props,State>

    第一个参数是组件的props类型,第二个参数是组件的State,与函数一样,范型参数之间使用逗号。

  •  使用&操作符表示 and 操作,如果代码这样写,是不是就理解了?

type Props = RouteComponentProps & WithTranslation
class HeaderComponent extends React.Component<Props, LanguageState>


3
1
你不懂我胖虎
非常感谢!
2021-01-20
共1条回复

你不懂我胖虎

提问者

2021-01-19

class HeaderComponent extends React.Component<RouteComponentProps & WithTranslation, LanguageState>  

代码是这样的

0
0

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

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

1993 学习 · 1015 问题

查看课程