React/TypeScript: extending a component with additional properties

前端 未结 5 601
梦如初夏
梦如初夏 2021-02-01 16:05

I am trying to use react to recreate my currents components (written in pure typescript) but I can\'t find a way to give additional props to a component extending an other.

5条回答
  •  执念已碎
    2021-02-01 16:39

    Keep in mind that what you are doing is an anti-pattern. React recommends using composition over inheritance.

    "At Facebook, we use React in thousands of components, and we haven’t found any use cases where we would recommend creating component inheritance hierarchies."

    More info: https://reactjs.org/docs/composition-vs-inheritance.html

提交回复
热议问题