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

react-switch: Adjust signature to use ForwardRefComponent #20093

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Adds ForwardRefComponent to react-switch components declaration",
"packageName": "@fluentui/react-switch",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 2 additions & 1 deletion packages/react-switch/etc/react-switch.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
import * as React_2 from 'react';

// @public
export const renderSwitch: (state: SwitchState) => JSX.Element;

// @public
export const Switch: React_2.ForwardRefExoticComponent<SwitchProps & React_2.RefAttributes<HTMLDivElement>>;
export const Switch: ForwardRefComponent<SwitchProps>;

// @public (undocumented)
export interface SwitchCommons {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-switch/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { useSwitch } from './useSwitch';
import { renderSwitch } from './renderSwitch';
import { useSwitchStyles } from './useSwitchStyles';
import type { SwitchProps } from './Switch.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';

/**
* The Switch control enables users to trigger an option on or off through pressing on the component.
*/
export const Switch = React.forwardRef<HTMLDivElement, SwitchProps>((props, ref) => {
export const Switch: ForwardRefComponent<SwitchProps> = React.forwardRef((props, ref) => {
const state = useSwitch(props, ref);

useSwitchStyles(state);
Expand Down