File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -178,8 +178,8 @@ export const useEditable = (
178
178
if ( ! opts ) opts = { } ;
179
179
180
180
const unblock = useState ( [ ] ) [ 1 ] ;
181
- const state : State = useState ( ( ) => {
182
- const state : State = {
181
+ const createInitialState = ( onChange : any ) : State => {
182
+ const initialState : State = {
183
183
observer : null as any ,
184
184
disconnected : false ,
185
185
onChange,
@@ -190,13 +190,14 @@ export const useEditable = (
190
190
} ;
191
191
192
192
if ( typeof MutationObserver !== 'undefined' ) {
193
- state . observer = new MutationObserver ( batch => {
194
- state . queue . push ( ...batch ) ;
193
+ initialState . observer = new MutationObserver ( mutations => {
194
+ initialState . queue . push ( ...mutations ) ;
195
195
} ) ;
196
196
}
197
197
198
- return state ;
199
- } ) [ 0 ] ;
198
+ return initialState ;
199
+ } ;
200
+ const state : State = useState ( ( ) => createInitialState ( onChange ) ) [ 0 ] ;
200
201
201
202
const edit = useMemo < Edit > (
202
203
( ) => ( {
You can’t perform that action at this time.
0 commit comments