react组件定义Props和States类型的时候用type还是interface?

唯见长江天际流
  • 639

react组件定义Props和States类型的时候用type还是interface?

回复
阅读 383
1 个回答

When it comes to types or interfaces, we suggest following the guidelines presented by the react-typescript-cheatsheet community:

  • “always use interface for public API’s definition when authoring a library or 3rd-party ambient type definitions.”
  • “consider using type for your React Component Props and State, because it is more constrained.”
宣传栏