score:3
Accepted answer
it's the spread properties syntax and it's creating a shallow copy of this.state.cars
. that means that this line:
cars[`car-${timestamp}`] = car;
doesn't result in an additional key being added to this.state.cars
. that is, it's being used specifically so that this.state.cars
is not mutated.
for spread properties to be included in your babel configuration, you'd need to be using the babel-plugin-syntax-object-rest-spread
and babel-plugin-transform-object-rest-spread
plugins - which are included in the stage-2
preset.
Source: stackoverflow.com
Related Query
- Getting Destructuring error with Rest operator?
- Using gulp/webpack and getting unexpected token error with spread operator
- Getting a TS2339 error with optional property declaration when destructuring
- Getting an error "A non-serializable value was detected in the state" when using redux toolkit - but NOT with normal redux
- CORS error while consuming calling REST API with React
- react with Rails 5, getting CSRF error for post with axios
- Getting npm ERR! exited with error code: 128
- Why am I getting this error - 'You are calling withTheme(Component) with an undefined component.' -React JS
- Getting an error trying to start React right after (There might be a problem with the project dependency tree....)
- using react with redux and Getting error in redux '=' expected
- Getting TS error with Redux dispatch action, `Property does not exist on type`
- Typescript throws error with spread operator
- getting bundle error when trying to load svg with raw-loader
- creating a bar chart using Highcharts with React - getting an error that rendering div isn't found
- Still getting "React state update on an unmounted component" error with React Testing Library tests
- Getting a parsing error in with React.js
- Getting Error while uploading file to S3 with Federated Identity using aws-amplify in React
- destructuring props with the rest properties
- Typescript optional chaining combined with ternary operator parsing error
- Getting error trying to use use Storybook with react-admin "useField must be used inside of a <Form> component"
- Trying to integrate jest and react with amchart but getting an error . What could be the issue?
- Spread operator error with React and Redux
- Django REST and React - JWT Cookie not getting set in browser but working with postman
- Combining objects with object destructuring and the turnary operator
- I have been trying to create a new react project with npx create-react-app, but I am getting an error
- getting error on conditional rendering with stateless component
- Why am I getting a jsx-loader error when I try to use react-router with webpack>
- Getting a "Too many re-renders" error with React Hooks
- Error with && logical operator jsx and typescript
- Getting "No overload matches this call" error when using useQuery with TypeScript
More Query from same tag
- API call / state in an EventHandler is always one step behind - cant fix it with an useEffect
- how to render component on onClick event handler
- React render instagram feeds from data.json
- how react use this keyword in arrow functions
- React functional component is not rendering when updating the Sate after pushing data to array
- ReactJS : use state is not working for only one state
- convert TZ date format to "dd/mm/yy hh:mm:ss" in Javascript
- window is not defined - react-draft-wysiwyg used with next js (ssr)
- How to Open React Native Expo Camera On Button Click
- react using usecontext, urereducer and usememo: yyy is missing the following properties from type yyy ts2739 error
- ReactJS and Laravel, nested route is not working. It bring me to the same page
- Checking if array element exists in another array
- problems with node js https on windows server
- How to make 2 audio files playable as 1 in React?
- Sanctum with react SPA returning 419 page expired
- How do I conditionally render certain data while using useEffect and setState?
- Can't create a React component in node_modules and use it in an application
- router.query not updated after router.push in next/router
- React: clicked link versus direct link
- Jest: Specific selector
- React Redux add line-through on checkbox click
- Why does useEffect doesn't update state on element delete
- Navbar dropdowns stop working when added a modal
- How to display object in ReactJS
- whole app resets if I dispatch action on submit , but it is ok if I dispatch the same action on the load of component
- How can we easily remove an element from an multi dimensional array object in react js
- Fetch API cannot load, cors
- React: How do I only render a component on the page once I click on it from a mapped array?
- How can I get the object which has been changed and also the new changed value when Selecting options from the drop down
- Error: Module not found: Can't resolve 'nativescript-xmpp-client' in '/home/rakesh95/Projects/webapp/node_modules/quickblox/src/modules/chat'