Skip to content

Commit 0931bab

Browse files
committed
fix: skip the first render so the anchor auto-generation only happens onchange
1 parent 7d01e08 commit 0931bab

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/block/heading/edit.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ const Edit = props => {
105105
const updateTimeout = useRef( null )
106106

107107
useEffect( () => {
108+
// Use updateTimeout to skip effect on first render
109+
if ( updateTimeout.current === null ) {
110+
updateTimeout.current = true
111+
return
112+
}
113+
108114
clearTimeout( updateTimeout.current )
109115
const anchor = props.attributes.anchor
110116
const text = props.attributes.text

0 commit comments

Comments
 (0)