score:8
Accepted answer
this is the syntax for parameter object destructuring, which was introduced as part of ecmascript 2015. the todos
function doesn't define a single parameter named todos
, but instead accesses the todos
property of an object that's passed in (and that is immediately destructured).
it is roughly equivalent to the following version:
const todos = (_param) => {
let todos = _param.todos;
return (
<div>
<h1>todos</h1>
{todos.map(todo => <p key={todo}>{todo}</p>)}
</div>
);
};
check out destructuring and parameter handling for more information on destructuring.
Source: stackoverflow.com
Related Query
- braces around params -- why?
- What is the significance of "{" "}" braces around this react library code?
- What do curly braces around a variable in a function parameter mean
- Why can't I get query params in ```getStaticProps```?
- Next.js static site generation, why is getStaticProps params empty?
- Why query params are disappearing from the url?
- Why do I need curly braces for nested JSX, even if it is working without it
- Why is ( ) used instead of curly braces / brackets { } inside Javascript Map function?
- Why Curly braces while handling a Promise object provides undefined data?
- Why are there parentheses around the value for count in this snippet?
- Why router navigates me into homepage when i'm changing my query params in url reactjs
- Why functions are written without braces in ReactJS?
- why i dont get nothing in nextjs in first load (css and params in getInitialProps)
- Why does adding/removing curly braces in this arrow function cause the text to not display for a ReactJS component?
- In React, why am I getting these errors around Promises?
- Why do we need double braces in this javascript function?
- why is that there is a dark area around the buttons when they are tapped on mobile devices
- why do we use curly braces while defining constant variable in react js?
- why should we write props in curly braces while using in child component
- Why axios post in react is not read by the node server, when params are sent as object?
- Why render props is not working with Curly Braces in render function?
- Why is the content inside the curly braces not renderering in React.js
- Why search query params does not get the first chosen option
- Why parent state is not updating when I change a value on a child but it is working the other way around
- Why am I receiving twice the query params in React?
- Why I use params in getInitialProps they are undefined when build in Next.js
- Trying to build HOC to wrap around Signin, Why do I keep getting this error? on /signin route?
- Why the React Route with 2 optional params not matching a simple URL
- Why use Redux over Facebook Flux?
- Why do we need middleware for async flow in Redux?
More Query from same tag
- How to dynamically switch between firebase and firestore as the database and dispatch redux actions accordingly
- NEXTJS: Best way to populate and erase input field with params from useRouter and preserve "back button" history
- Dynamically adding components in react
- I am trying to create a calculator using react hooks. I was trying to get the current number and send it to the displayInput
- Render multiple React components in shorthand if condition
- React doesn't update on state change?
- Load Components Dynamically React Js with load more button
- react failed to compile module "conversational-form"
- Using backchannel with React Client - Bot framework
- Rendering a component within another component
- Creating graph with recharts with multiple data arrays
- react multiple layouts (route roots) with plainroutes
- Passing common prop to all components in MDX file, without adding the prop to each component
- React - Forwarding multiple refs
- how to know a component return null or element in react
- Promise.all Not Loading Images in React For Use In HTML Canvas
- Babel will not compile .test.js files while running Jest
- App: prop type `store` is invalid; it must be a function, usually from the `prop-types` package, but received `undefined`
- Video HTML tag is not playing in React.js
- How to fix populating React components based on JSON response?
- State not updated when setState is called from tinyMCE onAction method
- How do I replace the current component content with other component content in React
- Configure imports relative to root directory in create-react-library library
- React with Firebase - splitting authorisation between CRUD actions
- value is undefined react js redux
- How to prevent component from being re-rendered unnecessarily
- Is it possible to achieve something like HOC with classes - without classes in React?
- Click event won't fire on click on iOS devices but works as intended on desktop
- Reusable function to avoid repeating prop name with React Storybook's Knob plugin?
- Generate react.fragment for multiple items via function