React.js write components directly in HTML

前端 未结 2 1075
别跟我提以往
别跟我提以往 2020-12-21 08:20

I\'m very new to React.js but exploring it I expected something that I\'m not able to do.

Say that I have a component:

var SampleComponent = React.cr         


        
2条回答
  •  鱼传尺愫
    2020-12-21 08:55

    In a typical app you would have a high-level controller-view component mounted to the DOM this way, but that component would contain a hierarchy of child components in its render method to build up the structure of your interface. This is the idea of composable views which is an advantage of react. These child components can be used directly within the jsx of the parents' render methods in the same way you had hoped, so you really only have to call React.render once on the top-level component.

提交回复
热议问题