SpoilerButton.jsx 500 B

1234567891011121314151617181920
  1. import React, { useState } from 'react'
  2. import { Input, Button, Divider,Typography } from 'antd'
  3. const { Text, Link } = Typography;
  4. export const SpoilerButton = ({ text, children, style }) => {
  5. const [opened, setOpened] = useState(false)
  6. return (
  7. <>
  8. <Text type="secondary" strong
  9. onClick={() => {
  10. setOpened(!opened)
  11. }}
  12. style={style}
  13. >
  14. {text}
  15. </Text>
  16. {opened && children}
  17. </>
  18. )
  19. }