Skip to content

Commit

Permalink
feat(Loading): support explicit ID (#5798)
Browse files Browse the repository at this point in the history
This change supports specifying explicit ID to `<Loading>`. It allows
application to avoid rendering mismatch between SSR/CSR.

Fixes #5796.
  • Loading branch information
asudoh authored Apr 3, 2020
1 parent acf0592 commit 2e21f40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2937,6 +2937,9 @@ Map {
"description": Object {
"type": "string",
},
"id": Object {
"type": "string",
},
"small": Object {
"type": "bool",
},
Expand Down
8 changes: 7 additions & 1 deletion packages/react/src/components/Loading/Loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { prefix } = settings;
const getInstanceId = setupGetInstanceId();

function Loading({
id,
active,
className: customClassName,
withOverlay,
Expand All @@ -32,7 +33,7 @@ function Loading({
[`${prefix}--loading-overlay`]: true,
[`${prefix}--loading-overlay--stop`]: !active,
});
const loadingId = `loading-id-${instanceId}`;
const loadingId = id || `loading-id-${instanceId}`;
const spinnerRadius = small ? '26.8125' : '37.5';

const loading = (
Expand Down Expand Up @@ -73,6 +74,11 @@ function Loading({
}

Loading.propTypes = {
/**
* Provide an `id` to uniquely identify the label
*/
id: PropTypes.string,

/**
* Specify whether you want the loading indicator to be spinning or not
*/
Expand Down

0 comments on commit 2e21f40

Please sign in to comment.