Skip to content
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(Buttons): avoid warnings related to change in order of react hooks #1229

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ const renderButtonContent = ({
const defaultIconSize = small ? styles.iconSize.small : styles.iconSize.default;
const spinnerSizeRem = small ? styles.spinnerSize.small : styles.spinnerSize.default;

const buttonElement = renderButtonElement({
small,
content: children,
defaultIconSize,
TextContentRenderer,
});

const loadingButtonElement = renderButtonElement({
small,
content: loadingText,
defaultIconSize,
TextContentRenderer,
});

return (
<>
{/* text content */}
Expand All @@ -153,12 +167,7 @@ const renderButtonContent = ({
</div>
)}
<div style={{display: 'flex', alignItems: 'baseline'}}>
{renderButtonElement({
small,
content: children,
defaultIconSize,
TextContentRenderer,
})}
{buttonElement}
{withChevron && (
<div
style={{
Expand Down Expand Up @@ -197,12 +206,7 @@ const renderButtonContent = ({
: undefined
}
>
{renderButtonElement({
small,
content: loadingText,
defaultIconSize,
TextContentRenderer,
})}
{loadingButtonElement}
</div>

{/* loading content */}
Expand Down Expand Up @@ -231,16 +235,7 @@ const renderButtonContent = ({
}}
/>
)}
{loadingText ? (
<Box paddingLeft={8}>
{renderButtonElement({
small,
content: loadingText,
defaultIconSize,
TextContentRenderer,
})}
</Box>
) : null}
{loadingText ? <Box paddingLeft={8}>{loadingButtonElement}</Box> : null}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was causing the issue that I explain in the PR description

</div>
</>
);
Expand Down
Loading