Skip to content

Commit d892ef5

Browse files
committed
Add Idempotent JavaScript Operations
1 parent 4859b6d commit d892ef5

File tree

4 files changed

+402
-2
lines changed

4 files changed

+402
-2
lines changed

lib/components_guide_web/controllers/web_standards_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule ComponentsGuideWeb.WebStandardsController do
66
render(conn, "index.html", article: "intro")
77
end
88

9-
@articles ["url", "promise", "http-caching", "html", "http-headers"]
9+
@articles ["url", "promise", "http-caching", "html", "http-headers", "idempotent-javascript-operations"]
1010

1111
def show(conn, %{"id" => article}) when article in @articles do
1212
render(conn, "index.html", article: article)

lib/components_guide_web/templates/react_typescript/testing.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ getByRole('img', { name: 'New document' });
343343

344344
## Use accessible names
345345

346-
<table style="width: 100%; text-align: left;">
346+
<table>
347347
<thead>
348348
<tr>
349349
<th>Role name</th>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Zero Hook Dependencies
2+
# Opinionated React Hooks
3+
4+
## Don’t pass dependencies to `useEffect`
5+
6+
Before:
7+
8+
```js
9+
useEffect(() => {
10+
performSearch(searchQuery);
11+
}, [searchQuery]);
12+
```
13+
14+
After:
15+
16+
```js
17+
useEffect(() => {
18+
// Use an idempotent operation which can be requested multiple times safely.
19+
performSearch(searchQuery);
20+
});
21+
```
22+
23+
## Don’t `useRef` for state

0 commit comments

Comments
 (0)