File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -175,3 +175,28 @@ Generated by [AVA](https://avajs.dev).
175175 onClick: updateUser␊
176176 }, "Click Me"));␊
177177 }`
178+
179+ ## Array Update
180+
181+ > Snapshot 1
182+
183+ `import * as React from "react";␊
184+ ␊
185+ function App() {␊
186+ const [users, setUsers] = React.useState([{␊
187+ name: "reaper"␊
188+ }]);␊
189+ ␊
190+ const updateUser = () => {␊
191+ const _nextUsers = users.slice();␊
192+ ␊
193+ _nextUsers[0].name = "barelyhuman";␊
194+ setUser(_nextUsers);␊
195+ };␊
196+ ␊
197+ return /*#__PURE__*/React.createElement(React.Fragment, null, users.map(user => {␊
198+ return /*#__PURE__*/React.createElement("p", null, user.name);␊
199+ }), /*#__PURE__*/React.createElement("button", {␊
200+ onClick: updateUser␊
201+ }, "Click Me"));␊
202+ }`
You can’t perform that action at this time.
0 commit comments