mercredi 3 août 2022

How to wrap first element child from render function of React functional component?

How i can wrap child element/s from render function in React component? For example, i have component:

React functional component:

const Component = () => (
  <div>
    <p>Some p element</p>
  </div>
)

and i want to wrap only <p> element with something else. I want this result after wrapping:

Component after wrapping:

const Component = () => (
  <div>
    <Wrapper>
      <p>Some p element</p>
    </Wrapper>
  </div>
)

How can i do it? Thx

Aucun commentaire:

Enregistrer un commentaire