First a look in JSX. When you do (scenario 1):

<Component myProp={something} />

The something typically is a JavaScript expression.

When you use the spread operator, like (scenario 2):

<Component {...something} />

Then something should be a JavaScript object.

Your case

Considering objA and objB are two JavaScript objects, you can use them like scenario 2 above:

<Component {...objA} {...objB} />

And they should work as expected.

When you do:

let bothObjects = {...objA, ...arrB};
<Component {...bothObjects} />

Again, it works because bothObjects is too an object. Just one object that happens to have been built based on objA and objB.

The other case:

<Component {...{...objA,...objB}} />

May seem weird, but works perfectly. See, from scenario 2 above, JSX expects (in {...something}) that something is an object. And {...objA,...objB} is an object. Well, it's actually an expression that "returns" a value of object type, but it's the same. It works fine.

The last case:

<Component {...objA, ...objB} />

Does not work because the expresion objA, ...objB is not a JavaScript object. It actually means nothing, it is a syntax error. See the error message:

VM2296 babel.js:17994 Uncaught SyntaxError: Babel script: Unexpected token, expected }
  30 | 
  31 |       <Bob
> 32 |         {...objA, ...objB}
     |                 ^

As you can see, after the char A of ...objA, JSX just expected to find the }. But it found a , which is an error (Unexpected token).

What to use?

Considering all three forms that work:

let bothObjects = {...objA, ...arrB};
<Component {...bothObjects} />
<Component {...objA} {...objB} />
<Component {...{...objA,...objB}} />

To say which one is better is just a matter of taste. Pick whatever you think is more readable.

Answer from acdcjunior on Stack Overflow
Top answer
1 of 5
96

First a look in JSX. When you do (scenario 1):

<Component myProp={something} />

The something typically is a JavaScript expression.

When you use the spread operator, like (scenario 2):

<Component {...something} />

Then something should be a JavaScript object.

Your case

Considering objA and objB are two JavaScript objects, you can use them like scenario 2 above:

<Component {...objA} {...objB} />

And they should work as expected.

When you do:

let bothObjects = {...objA, ...arrB};
<Component {...bothObjects} />

Again, it works because bothObjects is too an object. Just one object that happens to have been built based on objA and objB.

The other case:

<Component {...{...objA,...objB}} />

May seem weird, but works perfectly. See, from scenario 2 above, JSX expects (in {...something}) that something is an object. And {...objA,...objB} is an object. Well, it's actually an expression that "returns" a value of object type, but it's the same. It works fine.

The last case:

<Component {...objA, ...objB} />

Does not work because the expresion objA, ...objB is not a JavaScript object. It actually means nothing, it is a syntax error. See the error message:

VM2296 babel.js:17994 Uncaught SyntaxError: Babel script: Unexpected token, expected }
  30 | 
  31 |       <Bob
> 32 |         {...objA, ...objB}
     |                 ^

As you can see, after the char A of ...objA, JSX just expected to find the }. But it found a , which is an error (Unexpected token).

What to use?

Considering all three forms that work:

let bothObjects = {...objA, ...arrB};
<Component {...bothObjects} />
<Component {...objA} {...objB} />
<Component {...{...objA,...objB}} />

To say which one is better is just a matter of taste. Pick whatever you think is more readable.

2 of 5
23

Rest parameters should be the last named argument of a function, you're passing two. You should divide both into separate props, like in your working example:

<Component {...objA} {...objB} />

In this example you have two props, the with Rest parameter is the first one.

function sum(...theArgs, q) {
 return theArgs.reduce((previous, current) => {
    return previous + current;
  });
}`

When I put the q parameter it gives me the error:

Error: parameter after rest parameter

EDIT: And @Omar is right, in this case there's no need for using Rest Parameters, since both are simple objects

🌐
CoreUI
coreui.io › blog › draft-how-to-replace-all-occurrences-of-a-string-in-javascript
Mastering the Spread Operator (<code>...</code>) in React.js · CoreUI
September 3, 2023 - Using the JavaScript Spread Operator in React Passing Props to React Components One of the most common uses of the spread operator in React is when passing props to child components.
Discussions

Spread operator with React component props
Can I use the spread operator to get all the props from a React component?, I know I can use destructuring to get the props in stateless functional component like this: const Example = ({name, age, address}) => { retu… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
7
0
November 3, 2018
What is the point of using the spread operator to pass props while also passing props individually?
...props contains all the properties that are not destructured from the object. It's called the rest operator. https://www.freecodecamp.org/news/javascript-rest-vs-spread-operators/ More on reddit.com
🌐 r/react
2
3
August 31, 2022
reactjs - Spread operator in react component props - Stack Overflow
Could someone tell me, how it is 3 dot spread does? I know it wanna passing a isActive(Boolean) into Component SideNavLink. If it true then it has those props. But, I'm wondering what the code does... More on stackoverflow.com
🌐 stackoverflow.com
HOC /Props and Spread Operators
Hello guys. I am learning React now. I’ve been struggling to understand the logic in the following code I provide below · We create a functional component Button that accepts two parameters, in this case children prop and a copy of an array or object from elsewhere as a prop. More on discuss.codecademy.com
🌐 discuss.codecademy.com
0
0
December 11, 2023
🌐
Zhenyong
zhenyong.github.io › react › docs › jsx-spread.html
JSX Spread Attributes | React
var props = { foo: 'default' }; var component = <Component {...props} foo={'override'} />; console.log(component.props.foo); // 'override' The ... operator (or spread operator) is already supported for arrays in ES6. There is also an ECMAScript proposal for Object Rest and Spread Properties.
🌐
Scrimba
scrimba.com › articles › react-spread-operator
How to use the spread operator (...) in React
January 31, 2023 - In the context of React, the spread operator can be used to spread an object of props onto an element in a React component, making it easier to pass down props to child components but more on that later!
🌐
DhiWise
dhiwise.com › post › how-to-simplify-your-react-code-with-the-spread-operator
The Ultimate Guide To Using The React Spread Operator
October 31, 2023 - ... Simplifies Code: The spread operator can significantly simplify your code. For example, it allows you to pass all props to a child component in a single line, rather than passing them one by one.
🌐
DEV Community
dev.to › arikaturika › passing-props-using-the-spread-operator-in-react-52e4
Passing props using the spread operator in React - DEV Community
January 13, 2021 - We can easily see that the more props we want to pass, the messier the code becomes. The firs example that came into my head was the CSS styles example but our variables can virtually contain anything we want. What we could do instead is store all the styles in an object and pass it from parent to child using the spread operator.
🌐
Medium
medium.com › @matthudson1509 › explicit-prop-spreading-in-react-explicitly-spread-the-️-ec061609ac69
Explicit Prop Spreading in React — {…{ explicitly, spread, the, ❤️ }} | by Matt Hudson | Medium
August 25, 2022 - The above example uses EPS to ... component, we are defining a single inline object. The outer curly braces specify to React that we want to spread props to a component....
Find elsewhere
🌐
freeCodeCamp
forum.freecodecamp.org › curriculum help
Spread operator with React component props - Curriculum Help - The freeCodeCamp Forum
November 3, 2018 - Can I use the spread operator to get all the props from a React component?, I know I can use destructuring to get the props in stateless functional component like this: const Example = ({name, age, address}) => { retu…
🌐
Rip Tutorial
riptutorial.com › passing down props using spread operator
React Tutorial => Passing down props using spread operator
var props = { foo: 'default' }; var component = <Component {...props} foo={'override'} />; console.log(component.props.foo); // 'override' Another case is that you also can use spread operator to pass only parts of props to children components, then ...
🌐
Medium
medium.com › @nickren93 › fun-fact-using-the-spread-operator-to-pass-multiple-props-in-react-28c594199402
Fun Fact: Using the Spread Operator to Pass Multiple Props in React | by Nick Ren | Medium
March 31, 2025 - If you spread an object while also passing individual props, the order determines which value takes precedence. ... Here, name="Jane Doe" will override name: "John Doe" from the user object since it's specified after the spread operator.
🌐
DhiWise
dhiwise.com › blog › design-converter › how-to-use-spread-props-in-react-for-better-components
Spread Props React Guide: Write Efficient Components Easily
January 17, 2025 - The spread operator, denoted by ..., is a powerful feature in JavaScript that simplifies passing props to React components. When you have an object containing multiple properties, you can easily spread these properties into a component.
🌐
Reddit
reddit.com › r/react › what is the point of using the spread operator to pass props while also passing props individually?
r/react on Reddit: What is the point of using the spread operator to pass props while also passing props individually?
August 31, 2022 -

I'm building a react component library and am confused as to why the example passes props via the spread operator but also passes those same props individually. Below is the code I am working with. Specifically I am looking at the Button component props and the StyledButton props. Any clarification would be great, thanks!

import React,{FC} from 'react'
import styled from 'styled-components';

import {  MouseEventHandler } from "react"
export interface ButtonProps {
    text?: string,
    primary?:boolean,
    disabled?: boolean,
    size?: "small" | "medium" | "large",
    onClick?: MouseEventHandler<HTMLButtonElement>
}

const StyledButton = styled.button<ButtonProps>`
    border: 0;
    line-height: 1;
    font-size: 15px;
    cursor: pointer;
    font-weight: 700;
    font-weight: bold;
    border-radius: 3px;
    display: inline-block;
    padding: ${props => props.size === "small"? "7px 25px 8px" : (props.size === "medium"? "9px 30px 11px" : "14px 30px 16px" )};
    color: ${props => props.primary? "#1b116e":"#ffffff"};
    background-color: ${props => props.primary ? "#6bedb5":"#1b116e"};
    opacity: ${props => props.disabled ? 0.5 : 1};
    &:hover {
      background-color: ${props => props.primary ? "#55bd90":"#6bedb5"};
    }
    &:active {
        border: solid 2px #1b116e;
        padding: ${props => props.size === "small"? "5px 23px 6px" : (props.size === "medium"? "7px 28px 9px" : "12px 28px 14px" )};
    }
`;

const Button: FC<ButtonProps> = ({size, primary, disabled, text, onClick, ...props}) => {
    return (
        <StyledButton type="button" onClick={onClick} primary={primary} disabled={disabled} size={size} {...props}>
            {text}
        </StyledButton>
    )
}

export default Button;
🌐
Medium
kevinyckim33.medium.com › jsx-spread-operator-component-props-meaning-3c9bcadd2493
JSX Spread Operator <Component {…props} /> Meaning | by Kevin Kim | Medium
September 27, 2019 - If you already have props as an object, and you want to pass it in JSX, you can use ... as a “spread” operator to pass the whole props object.
🌐
DMC, Inc.
dmcinfo.com › latest-thinking › blog › id › 9668 › 5-great-uses-of-the-spread-operator-in-a-react-app
5 Great Uses of the Spread Operator in a React App | DMC, Inc.
December 30, 2025 - Probably the most common usage of the spread operator in a React app is in passing props down to a child component. So long as the object you’re spreading includes all the properties the child component requires, the child component will use ...
🌐
DEV Community
dev.to › edriso › using-the-spread-operator-in-react-426e
Using the Spread Operator in React - DEV Community
January 5, 2026 - In this example, {...user} spreads the properties of the user object (name, age, and location) as individual props to the UserProfile component. This is equivalent to manually passing each prop like this: <UserProfile name={user.name} age={user.age} location={user.location} /> The spread operator can also be used to clone an object and update specific properties.
🌐
Medium
medium.com › @truongtronghai › spread-operator-ba867a0e97b4
Spread operator. Some ways to use it in React Js | by Truong Trong Hai | Medium
October 3, 2024 - }; const Card = ({ title, description ... setState(prevState => ({ ...prevState, age: 31 })); }; You can use the spread operator to merge arrays, which can be useful when dealing with lists in React....
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › what-is-the-meaning-of-spread-operator-in-reactjs
What is the Meaning of Spread Operator (...) in Reactjs? - GeeksforGeeks
July 23, 2025 - // For array expansion const array1 = [1, 2, 3]; const array2 = [...array1, 4, 5]; // [1, 2, 3, 4, 5] // Object Expansion const obj1 = { a: 1, b: 2 }; const obj2 = { ...obj1, c: 3 }; // { a: 1, b: 2, c: 3 } // Passing Props const childProps = { name: 'John', age: 25 }; <ChildComponent {...childProps} /> // Managing State this.setState((prevState) => ({ ...prevState, user: { ...prevState.user, name: "New Name" } })); The spread operator is very useful when you want to make an exact copy of an existing array, you can use the spread operator to accomplish this quickly. Step 1: Create a React application using the following command:
🌐
sebhastian
sebhastian.com › react-spread-props
Should you use spread attributes when passing props? | sebhastian
November 5, 2020 - When you find you need to pass multiple props, you can wrap them as an object and use the spread operator to pass the whole props object: function MainComponent(){ const props = { firstName: "Jack", lastName: "Skeld" } return <Hello {...props} ...
🌐
Codecademy Forums
discuss.codecademy.com › web development › full-stack
HOC /Props and Spread Operators - Full-Stack - Codecademy Forums
December 11, 2023 - Hello guys. I am learning React now. I’ve been struggling to understand the logic in the following code I provide below · We create a functional component Button that accepts two parameters, in this case children prop and a copy of an array or object from elsewhere as a prop.