Render function in reactjs

后端 未结 2 779
春和景丽
春和景丽 2021-01-06 06:29

Quick question. I\'m learning react js.

When we create a component, we provide in the render function the html template of the component to render. So far I have o

2条回答
  •  爱一瞬间的悲伤
    2021-01-06 07:01

    You should always write it in the render function. You're not writing HTML in there, you're writing JSX, which is compiled into Javascript. Something like

    is converted into React.createElement("div", {className: 'test'});.

    You shouldn't have an issue of size as long as you break down large components into a composition of many smaller components. You can include other components by including them in your render function, like this: .

提交回复
热议问题