Skip to content

Commit

Permalink
docs: update switch
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Nov 18, 2023
1 parent 7feb0be commit 3fbda29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { Button, Flex, Switch } from '@tonic-ui/react';
import React, { useRef } from 'react';
import React, { useCallback, useRef } from 'react';

const App = () => {
const inputRef = useRef();

const handleClick = () => {
const handleClick = useCallback(() => {
const inputEl = inputRef?.current;
if (inputEl) {
inputEl.focus();
window.alert('The switch toggle is ' + (inputEl.checked ? 'on' : 'off'));
}
};
}, []);

return (
<Flex alignItems="center" columnGap="6x">
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docs/pages/components/switch/index.page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Once you have obtained the reference to the input element, you can access its pr

Here's an example of how you can utilize the `inputRef` prop to access the input element and perform actions:

{render('./faq-input-element')}
{render('./faq-input-ref')}

## Props

Expand Down

0 comments on commit 3fbda29

Please sign in to comment.