Typescript Examples - Popover #2272
Answered
by
simonguo
Amir-Zouerami
asked this question in
Q&A
Replies: 2 comments
-
import Popover, { PopoverProps } from 'rsuite/Popover';
import Whisper, { WhisperInstance } from 'rsuite/Whisper';
interface MenuPopoverProps extends PopoverProps {
onSelect: (value: number) => void;
}
const MenuPopover = React.forwardRef(
({ onSelect, ...rest }: MenuPopoverProps, ref: React.Ref<HTMLDivElement>) => (
<Popover ref={ref} {...rest} full>
<Dropdown.Menu onSelect={onSelect}>
<Dropdown.Item eventKey={1}>New File</Dropdown.Item>
<Dropdown.Item eventKey={2}>New File with Current Profile</Dropdown.Item>
<Dropdown.Item eventKey={3}>Download As...</Dropdown.Item>
<Dropdown.Item eventKey={4}>Export PDF</Dropdown.Item>
<Dropdown.Item eventKey={5}>Export HTML</Dropdown.Item>
<Dropdown.Item eventKey={6}>Settings</Dropdown.Item>
<Dropdown.Item eventKey={7}>About</Dropdown.Item>
</Dropdown.Menu>
</Popover>
)
);
const WithDropdown = () => {
const ref = React.useRef<WhisperInstance>();
const handleSelectMenu = React.useCallback((eventKey: number, event) => {
console.log(eventKey, event);
ref.current.close();
}, []);
return (
<Whisper
placement="bottomStart"
controlId="control-id-with-dropdown"
trigger="click"
ref={ref}
speaker={<MenuPopover onSelect={handleSelectMenu} />}
>
<Button>File</Button>
</Whisper>
);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Amir-Zouerami
-
much appreciated 👍🏻 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can I get my hands on some Typescript examples?
For instance can anyone give me the typescript version of this:
example is from here: https://rsuitejs.com/components/popover/#used-with-dropdown
Beta Was this translation helpful? Give feedback.
All reactions