News for hackers. Stuff that matters.

bluebill1049

Thanks very much for sharing ️
Re:Show HN: React Hook Form – Simple Form Validation on Friday October 11, 2019 @04:26PM (#21228133)
yes, the right tool for the right job.
Re:Show HN: React Hook Form – Simple Form Validation on Thursday October 10, 2019 @11:50PM (#21221412)
no comment...
Re:Show HN: React Hook Form – Simple Form Validation on Thursday October 10, 2019 @11:49PM (#21221402)
it's beautiful when it all works, it's horrible when requirements changes.
Re:Show HN: React Hook Form – Simple Form Validation on Thursday October 10, 2019 @11:47PM (#21221395)
agree. it all looks good on paper until the requirement and design changes, then you are in world of pain.
Re:Show HN: React Hook Form – Simple Form Validation on Thursday October 10, 2019 @11:45PM (#21221386)
oh sweet! that's great to hear. my pleasure to help.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @06:45PM (#21208997)
interesting project! thanks for sharing
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:08PM (#21208088)
lol
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:03PM (#21208046)
Thank you very much byahya for your kind words and the lovely message. I am really glad could help you out with building forms. This is also one of the reasons why I am so passionate about building open source projects, be a dev only also me to solve particular within a product or project. it's so good we have an amazing community who are sharing their idea and code around the world. It's my 2 cents to give back the community and help out others and of course doing something meaningful in my life :) I really appreciated your feedback and your encouragement, feel free to ask a question or submit issues in the GitHub. <3
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @04:28PM (#21207643)
wow thanks, chatmasta, I am really glad to hear this great feedback! I would like to put the credit towards React Hook because it really saves us to write less code and not to worry too much about the lifecycle methods.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @04:25PM (#21207609)
I am not exactly sure what are you referring to, but I think this lib is pretty small compared with what is currently on the market, and I have tried my best, time and effort to keep the package as small and feature-rich as it can be, but I love constructive critisim and if you have better solution or reckon code can be improved, please submit a PR and it would do me a favor and also the rest of the community, because I built this not just me for but for other devs around the wrold. thanks
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @04:19PM (#21207541)
yea, I have been working forms for a while, there is hardly a page where a form just couple inputs and a submit button. There are conditional display, design and UX requirements. I can see this working for a one-page simple form.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @04:17PM (#21207513)
Agree, also there is also UI and UX's input on how the form should behave and its looking feel, it's not always just couple inputs and a submit button :)
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @08:17AM (#21202429)
I agree. the lib itself is primitive enough for you to build a JSON formate to generate forms. here is an good example: https://github.com/start-at-root/react-breeze-form
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @08:14AM (#21202404)
wow so cool~ https://picnicss.com/ love it. stared the project. <3
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @07:58AM (#21202306)
hey, nice lib you got there :) When I was deciding the API, I did have the idea of just collecting form input automatically (similar to forn), but there are few reasons which lead to the final decision:

1. Support React controlled component. eg some of the popular component libs, they are wrapped input inside their component and it's hard to predict which to include during the form submit.

2. React Native <3

3. Attach validation rules, messages and async validation on the individual field level.

Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @07:22AM (#21202061)
This is a really good reply! In fact, React hook form is based on uncontrolled components, I guess the mainstream is still controlled, but I would like to give some fo the love to uncontrolled and explore the benefits from it.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @07:15AM (#21202013)
everything is about pros and cons. there is no silver bullet for building form if you enjoy building a form with JSON schema good for you too. Thanks for checking it out tho :)
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @06:17AM (#21201725)
sounds good. i will be looking into that :)
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @06:01AM (#21201657)
Sorry I meant once I made it work, and it will be the syntax
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @06:00AM (#21201652)
I haven't got a plan to look into class component just yet, but will do in the near future.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:55AM (#21201626)
import React from 'react'; import useForm from 'react-hook-form';

function App() {

  const { register, handleSubmit, errors } = useForm(); // initialise the hook

  const onSubmit = data => {
    console.log(data);
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstname" ref={register} /> {/* register an input */}
      
      <input name="lastname" ref={register({ required: true })} />
      {errors.lastname && 'Last name is required.'}
      
      <input name="age" ref={register({ pattern: /\d+/ })} />
      {errors.age && 'Please enter number for age.'}
      
      <input type="submit" />
    </form>
  );
}

here is an code example, there is no local state.

Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:54AM (#21201622)
yea would be similar for class component :)
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:39AM (#21201542)
That’s it! React hook form is basically doing that :) it’s uncontrolled.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:27AM (#21201482)
Thank you so much for those kind words. This means so much to me seriously. I love making things and especially when others are enjoy to use. I will keep improving the site and package. Feel free to ask questions in github :) again thank you <3
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:19AM (#21201448)
By the way I did have a folder of examples as well. Quite lot of them: https://github.com/react-hook-form/react-hook-form/tree/mast... with codesandbox link too
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:17AM (#21201440)
That sounds like a great idea! Maybe I should set up some quick templates.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:12AM (#21201422)
Sure I will looking into it and add to the comparison.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @05:11AM (#21201420)
Thank you. I was try to giving everyone some good context why built this form lib.
Re:Show HN: React Hook Form – Simple Form Validation on Wednesday October 09, 2019 @04:36AM (#21201223)
Hi guys,

I have built a custom hook for form validation, please check it out and feedback welcome <3

Older »