How to pass down props down to a React component having same keys and values

Viewed 52

I have something like this in my JSX file. Since I'm using same key and value for props, is there a way I can send all the props at once with shorter notation?

{footer.map(({style, icon}, index) => (
  <Div>
    <ToggleIcon style={style} icon={icon} />
  </Div>
))}
1 Answers

If you wish to send all the props down to the components without destructing the values, then all you have to do is this.

{footer.map((props, index) => (
  <Div>
    <ToggleIcon {...props} />
  </Div>
))}
Related