-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Document useEntityRecord/s in README.md and CHANGELOG.md #40932
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
Conversation
Co-authored-by: Greg Ziółkowski <[email protected]>
…ress/gutenberg into update/document-use-entity-records
|
Size Change: +783 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
|
I tried the following changes locally: diff --git a/packages/core-data/src/hooks/index.ts b/packages/core-data/src/hooks/index.ts
index bdd1ad8adc..ea1aa1c49c 100644
--- a/packages/core-data/src/hooks/index.ts
+++ b/packages/core-data/src/hooks/index.ts
@@ -1,8 +1,8 @@
export {
- useEntityRecord,
+ default as useEntityRecord,
__experimentalUseEntityRecord,
} from './use-entity-record';
export {
- useEntityRecords,
+ default as useEntityRecords,
__experimentalUseEntityRecords,
} from './use-entity-records';
diff --git a/packages/core-data/src/hooks/use-entity-record.ts b/packages/core-data/src/hooks/use-entity-record.ts
index 3c749b97dc..eb96cbfab2 100644
--- a/packages/core-data/src/hooks/use-entity-record.ts
+++ b/packages/core-data/src/hooks/use-entity-record.ts
@@ -70,7 +70,7 @@ export interface Options {
* @return Entity record data.
* @template RecordType
*/
-export function useEntityRecord< RecordType >(
+export default function useEntityRecord< RecordType >(
kind: string,
name: string,
recordId: string | number,
@@ -92,8 +92,6 @@ export function useEntityRecord< RecordType >(
};
}
-export default useEntityRecord;
-
export function __experimentalUseEntityRecord(
kind: string,
name: string,
diff --git a/packages/core-data/src/hooks/use-entity-records.ts b/packages/core-data/src/hooks/use-entity-records.ts
index 2d51f778cb..2dbc83bf66 100644
--- a/packages/core-data/src/hooks/use-entity-records.ts
+++ b/packages/core-data/src/hooks/use-entity-records.ts
@@ -59,7 +59,7 @@ const EMPTY_ARRAY = [];
* @return Entity records data.
* @template RecordType
*/
-export function useEntityRecords< RecordType >(
+export default function useEntityRecords< RecordType >(
kind: string,
name: string,
queryArgs: Record< string, unknown > = {},
@@ -90,8 +90,6 @@ export function useEntityRecords< RecordType >(
};
}
-export default useEntityRecords;
-
export function __experimentalUseEntityRecords(
kind: string,
name: string,
diff --git a/packages/core-data/src/index.js b/packages/core-data/src/index.js
index d99d591858..05cace07c9 100644
--- a/packages/core-data/src/index.js
+++ b/packages/core-data/src/index.js
@@ -68,12 +68,7 @@ export const store = createReduxStore( STORE_NAME, storeConfig() );
register( store );
export { default as EntityProvider } from './entity-provider';
-export {
- useEntityRecord,
- __experimentalUseEntityRecord,
- useEntityRecords,
- __experimentalUseEntityRecords,
-} from './hooks';
export * from './entity-provider';
-export * from './fetch';
export * from './entity-types';
+export * from './fetch';
+export * from './hooks';It seems to work correctly and resolves the issue you encountered in #40932 (comment). |
gziolo
left a comment
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.
I re-triggered failing jobs that seemed unrelated to these changes. If they pass we should be good to go.
I also included a diff with potential changes to how the files are imported. We could benefit from some better guidelines how to handle that on the project level.
Thank you so much for improving the documentation ❤️
|
Great patch @gziolo, it did the trick! Let's wait for the CI and merge this. |
What?
As @gziolo noted in #40162 (comment):
This PR does just that
Testing Instructions