-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Refactor usage of __unstableGetClientIdsTree #3104
fix: Refactor usage of __unstableGetClientIdsTree #3104
Conversation
🤖 Pull request artifacts
|
const [ blockCount, setBlockCount ] = useState( null ) | ||
|
||
// Subscribe to all editor changes, so we can listen in to block structure changes. | ||
subscribe( () => { | ||
const count = select( 'core/block-editor' ).getGlobalBlockCount() | ||
if ( count !== blockCount ) { | ||
setBlockCount( count ) | ||
} | ||
} ) | ||
|
||
useEffect( () => { | ||
if ( blockCount ) { | ||
dispatch( 'stackable/block-editor' ).updateClientTree() | ||
} | ||
}, [ blockCount ] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we see if using getClientIdsWithDescendants
will help with this?
const [ blockCount, setBlockCount ] = useState( null ) | |
// Subscribe to all editor changes, so we can listen in to block structure changes. | |
subscribe( () => { | |
const count = select( 'core/block-editor' ).getGlobalBlockCount() | |
if ( count !== blockCount ) { | |
setBlockCount( count ) | |
} | |
} ) | |
useEffect( () => { | |
if ( blockCount ) { | |
dispatch( 'stackable/block-editor' ).updateClientTree() | |
} | |
}, [ blockCount ] ) | |
const allClientIds = useSelect( select => { | |
return select( 'core/block-editor' ).getClientIdsWithDescendants() | |
} ) | |
useEffect( () => { | |
console.log('did update' ) | |
dispatch( 'stackable/block-editor' ).updateClientTree() | |
}, [ allClientIds ] ) |
…-tapiamkr:gambitph/Stackable into fix/2798-refactor-__unstableGetClientIdsTree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have 2 stores for this purpose:
src/hooks/use-block-context.js
src/plugins/get-client-id-tree/store.js
I believe both of these are used solely for updating block context, so we should be able to combine these into just one.
fixes #2798