Is there a way to render multiple React components in the React.render() function?

后端 未结 8 1224
无人共我
无人共我 2020-12-08 06:33

For example could I do:

import React from \'react\';
import PanelA from \'./panelA.jsx\';
import PanelB from \'./panelB.jsx\';

React.render( 
  

        
8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 07:05

    You can do it like this too.

    const list = [item1, item2]
    const elements = (
        
    {list.map(element => element)}
    ); ReactDOM.render(elements, document.body);

提交回复
热议问题