Skip to content

Commit 59d79dd

Browse files
committed
use layout effect (in 2.1.3)
1 parent 6d400e0 commit 59d79dd

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
### 2.1
66

77
- `useOnly` returns `undefined` before being initialized
8+
- fix bugs
89

910
<details>
1011
<summary>See detailed changelog</summary>
1112

13+
#### 2.1.3
14+
15+
- re-use `useLayoutEffect` to reduce delay between initialization and true values
16+
1217
#### 2.1.2
1318

1419
- fix non-valid breakpoints

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-only",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "🔍 <Only /> displays some contents for a specific screen size",
55
"source": "src/index.ts",
66
"main": "lib/react-only.js",

‎src/useOnly.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const useOnly = (on?: string, media?: string, strict?: boolean) => {
1818
[toMediaQuery, on, media, strict]
1919
);
2020

21-
React.useEffect(() => {
21+
React.useLayoutEffect(() => {
2222
if (!mediaQuery) {
2323
return;
2424
}

0 commit comments

Comments
 (0)