Demo.tsx 943 B

123456789101112131415161718192021222324252627282930313233
  1. import React, { useEffect } from 'react';
  2. import Input from '../index';
  3. import InputGroup from '../inputGroup';
  4. // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
  5. const Demo = () => {
  6. const ref = React.useRef(null);
  7. useEffect(() => {
  8. if (ref.current) {
  9. ref.current.focus();
  10. }
  11. }, [ref.current]);
  12. return (
  13. <div>
  14. <Input
  15. placeholder="aaaa"
  16. prefix={(<span>Prefix</span>)}
  17. // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
  18. onChange={(v, e) => console.log(e)}
  19. showClear
  20. />
  21. <hr />
  22. <InputGroup>
  23. <Input placeholder="Input" style={{ width: 100 }} ref={ref} />
  24. <Input placeholder="Group" style={{ width: 200 }} />
  25. </InputGroup>
  26. </div>
  27. );
  28. };
  29. export default Demo;