Loading tutorials
useState hook, and React event handlers.2 min readuseState and handle events.2 min readuseState, and how to handle events in React. It covers how to update object state by building a new object and passing it to the setter.2 min readuseState in function components. You have already seen that setPerson({ ...person, firstName: 'Grace' }) replaces state with a new object. Here you will see what that copy contains and where it stops.2 min readuseState and handles events. Earlier chapters showed that spread copies an object one level deep. Here you apply that to objects that contain other objects.2 min readmap, filter, and slice methods, the spread operator, and the basics of useState in a function component.2 min readuseState and event handlers. Here you will add items to an array in state without mutating it.2 min readfilter and splice in JavaScript, can write a function component with useState, and have read the earlier chapters on treating state as read-only. Here you will remove items from an array in state without mutating it.2 min readmap and filter, and basic useState usage with event handlers in function components.2 min readuseState, event handlers, the spread operator, and slice. It builds on the earlier chapter about adding items to the end of an array.2 min readuseState, event handlers, the spread operator, and how map, filter, and slice work. You should also know that React compares state by reference. If you pass the setter the same array, React sees no change.2 min readmap and useState. It combines the two. State often holds an array of objects, such as todos, cart lines, or users. Changing one field on one of those objects takes more care than either pattern alone.2 min readuseState, event handlers, the spread operator, and map and filter. You have already seen how to replace state with a new copy. Here you will learn what to do when the new value depends on the old one and you set state more than once in the same event.2 min readmap, and filter, and that you have used useState in function components. Here you will see why deeply nested state is painful to update, and how to reshape it so updates stay short.2 min readmap and filter, useState, and the copy-based update patterns from earlier chapters. Here you will see how Immer lets you write the same updates with less code.2 min read