-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add useSettings hook for reading multiple settings at once #55337
Changes from all commits
02d9b61
d157e18
501b039
ffd13a2
5c88662
09becfc
bf20388
938b1ff
9740868
79e62a3
c994be1
2205c38
0160429
f8beb3e
c8e020c
7e530bc
9ebf699
8a312be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -944,9 +944,11 @@ _Parameters_ | |
|
||
### useSetting | ||
|
||
> **Deprecated** 6.4.0 Use useSettings instead. | ||
|
||
Hook that retrieves the given setting for the block instance in use. | ||
|
||
It looks up the settings first in the block instance hierarchy. If none is found, it'll look it up in the block editor store. | ||
It looks up the setting first in the block instance hierarchy. If none is found, it'll look it up in the block editor settings. | ||
|
||
_Usage_ | ||
|
||
|
@@ -962,6 +964,26 @@ _Returns_ | |
|
||
- `any`: Returns the value defined for the setting. | ||
|
||
### useSettings | ||
|
||
Hook that retrieves the given settings for the block instance in use. | ||
|
||
It looks up the settings first in the block instance hierarchy. If none are found, it'll look them up in the block editor settings. | ||
|
||
_Usage_ | ||
|
||
```js | ||
const [ fixed, sticky ] = useSettings( 'position.fixed', 'position.sticky' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused here because the PR description says const [ allowFixed, allowSticky ] = useSettings( [ 'position.fixed', 'position.sticky' ] ); Can both be used? It would be nice to be consistent so we don't need to normalise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the The main reason for that was that when reading a single setting, |
||
``` | ||
|
||
_Parameters_ | ||
|
||
- _paths_ `string[]`: The paths to the settings. | ||
|
||
_Returns_ | ||
|
||
- `any[]`: Returns the values defined for the settings. | ||
|
||
### Warning | ||
|
||
_Related_ | ||
|
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.
Should we add a note right here that it's deprecated in favor of
useSettings()
?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.
Note added 👍