How to avoid extra wrapping
in React?

前端 未结 10 1042
孤独总比滥情好
孤独总比滥情好 2020-12-02 12:04

Today I have started learning ReactJS and after an hour faced with the problem.. I want to insert a component which has two rows inside a div on the page.A simplified exampl

10条回答
  •  盖世英雄少女心
    2020-12-02 12:22

    This requirement was removed in React version (16.0)]1, so now you are able to avoid that wrapper.

    You can use React.Fragment to render a list of elements without creating a parent node, official example:

    render() {
      return (
        
          
          
          
        
      );
    }
    

    More here: Fragments

提交回复
热议问题