import React from 'react' ; import { PrimaryButton } from '@workday/canvas-kit-react/button' ; import { FormField } from '@workday/canvas-kit-react/form-field' ; import { Switch } from '@workday/canvas-kit-react/switch' ; export const RefForwarding = ( ) => { const [ checked , setChecked ] = React . useState ( false ) ; const ref = React . useRef ( null ) ; const handleChange = ( event ) => { setChecked ( event . target . checked ) ; } ; const handleClick = ( ) => { ref . current . focus ( ) ; } ; return ( < > < FormField label = "Dark Mode" > < Switch checked = { checked } onChange = { handleChange } ref = { ref } / > < /FormField> < PrimaryButton onClick = { handleClick } > Focus Switch < /PrimaryButton> < />); } ;