Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/beige-bananas-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/clerk-react": patch
---

Fix `signOutOptions` prop usage in `<SignOutButton />` component
2 changes: 1 addition & 1 deletion packages/react/src/components/SignOutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const SignOutButton = withClerk(
children = normalizeWithDefaultValue(children, 'Sign out');
const child = assertSingleChild(children)('SignOutButton');

const clickHandler = () => clerk.signOut({ redirectUrl });
const clickHandler = () => clerk.signOut({ redirectUrl, ...signOutOptions });
const wrappedChildClickHandler: React.MouseEventHandler = async e => {
await safeExecute((child as any).props.onClick)(e);
return clickHandler();
Expand Down
20 changes: 20 additions & 0 deletions packages/react/src/components/__tests__/SignOutButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jest.mock('../withClerk', () => {
};
});

const url = 'https://www.clerk.com';

describe('<SignOutButton />', () => {
beforeAll(() => {
console.error = jest.fn();
Expand All @@ -46,6 +48,24 @@ describe('<SignOutButton />', () => {
});
});

it('handles redirectUrl prop', async () => {
render(<SignOutButton redirectUrl={url} />);
const btn = screen.getByText('Sign out');
userEvent.click(btn);
await waitFor(() => {
expect(mockSignOut).toHaveBeenCalledWith({ redirectUrl: url });
});
});

it('handles signOutOptions prop', async () => {
render(<SignOutButton signOutOptions={{ redirectUrl: url, sessionId: 'sess_1yDceUR8SIKtQ0gIOO8fNsW7nhe' }} />);
const btn = screen.getByText('Sign out');
userEvent.click(btn);
await waitFor(() => {
expect(mockSignOut).toHaveBeenCalledWith({ redirectUrl: url, sessionId: 'sess_1yDceUR8SIKtQ0gIOO8fNsW7nhe' });
});
});

it('uses text passed as children', async () => {
render(<SignOutButton>text</SignOutButton>);
screen.getByText('text');
Expand Down
Loading