I am unable to get why do we use something like {...props}
For example in my code (when I am learning router) I do something like this
import React from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import Home from './home.js';
const route = () => {
return(
<BrowserRouter>
<Switch>
<Route path ="/" render ={(props) => <Home {...props}/>} />
</Switch>
</BrowserRouter>
)
}
export default route;
Here, this pass on the function/and probably calls it giving him the props
import React from 'react';
const home = (props) => {
console.log(props)
return (
<div> home </div>
);
}
export default home;
This would log something like this
{match: {…}, location: {…}, history: {…}, staticContext: undefined}
But If I remove {...props} from our home , it won't log this
{match: {…}, location: {…}, history: {…}, staticContext: undefined}
Can anyone please explain in steps/or in length what happens and why do we need it?