Skip to content

Commit

Permalink
react-switch: Adjust signature to use ForwardRefComponent (#20093)
Browse files Browse the repository at this point in the history
* Adds ForwardRefComponent to react-switch components declaration

* Change files
  • Loading branch information
bsunderhus authored Oct 4, 2021
1 parent a26b3ef commit e14cbc6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
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

0 comments on commit e14cbc6

Please sign in to comment.