Skip to main content

Blocks SDK Request: Add onFocus & onBlur handler to Input component

  • September 16, 2020
  • 0 replies
  • 4 views

Andy_Cloke
Forum|alt.badge.img+17

The Input component is missing onFocus & onBlur handlers, which are pretty useful for e.g. form validation. At the moment the only way around it it is to use refs which gets pretty messy.
Current doing this:

...
useEffect(() => {
    if (inputRef && inputRef.current) {
      inputRef.current.onblur = console.log;
    }
  }, [inputRef]);

return (
       <Input
       ref={inputRef}
       value={value}
       onChange={handleChange}
/>
)

When I’d love to do this:

return (
       <Input
       onBlur={console.log}
       value={value}
       onChange={handleChange}
/>

0 replies

Be the first to reply!