index.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import React from 'react';
  2. import Form from './Form';
  3. import SharedTile from '../Utils/SharedTitle';
  4. import Code from '../Utils/Code';
  5. const FormDemo = () => {
  6. return (
  7. <div>
  8. <SharedTile />
  9. <p>
  10. This form is constructed purely in React without any external library.
  11. The placeholders and validation are implemented in pure Javascript, thus
  12. no HTML5 is required and more importantly, the style of placeholders and
  13. warnings are easy to control. However, implementing good validation
  14. logic on large forms is still challegning in react as the code could
  15. become extremely verbose and repeative. A library is still required to
  16. handle more professional and long forms with complex validation process.
  17. In addition, using <Code>setState</Code> multiple times in one function
  18. can lead to sublte bugs as this <Code>setState</Code> is asynchronous.
  19. Updating the state with <Code>setState</Code> then checking certain
  20. conditions based on the new state in one function does not work. Use a
  21. callback function in <Code>setState</Code> instead.
  22. </p>
  23. <hr />
  24. <Form />
  25. </div>
  26. );
  27. };
  28. export default FormDemo;