Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textarea support? #11

Closed
samholmes opened this issue Jan 15, 2019 · 1 comment
Closed

Textarea support? #11

samholmes opened this issue Jan 15, 2019 · 1 comment
Labels
enhancement Improve existing functionality

Comments

@samholmes
Copy link

I don't see any example of using this with a textarea element.

@wsmd wsmd mentioned this issue Jan 17, 2019
2 tasks
@wsmd wsmd added the enhancement Improve existing functionality label Jan 17, 2019
@wsmd wsmd closed this as completed in #12 Jan 17, 2019
@wsmd
Copy link
Owner

wsmd commented Jan 17, 2019

Hi @samholmes! Thanks for reporting the issue!

You are absolutely right. Up until v0.3.0, the library had no explicit support for textareas. Although it was possible to apply {...input.text()} on a <textarea> element, I am afraid that wasn't ideal because:

  • it is not very intuitive
  • it applies unnecessary type="text" attribute on textareas.

I just released version 0.4.0 which added support for textareas, With the latest version, you could do something like this:

import { useFormState } from 'react-use-form-state';

function Form() {
  const [formState, { textarea }] = userFormState();
  return (
    <form onSubmit={() => console.log(formState)}>
      <textarea {...textarea('description')} />
    </form>
  )
}

The website has also been updated with a proper example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants