React JSX vs function call to present component

做~自己de王妃 提交于 2020-08-23 09:50:23

问题


const Component = ({ text }) => (
  <div>{text}</div>
)

const Example = () => (
  <div>
    <Component text="123" />
    {Component({ text: "123" })}
  </div>
)

Is there any difference between the two methods of rendering? Which is preferred and why?


回答1:


Yes, the second is faster because it's not mounted with React.createElement. See this great article by Philippe Lehoux that talks about the differences (mainly in performance) between both approaches.



来源:https://stackoverflow.com/questions/47288322/react-jsx-vs-function-call-to-present-component

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!