-
-
Notifications
You must be signed in to change notification settings - Fork 14
RHFInput + Semantic UI Select / Checkbox #21
Comments
Can you generate a codesandbox for this one? Thanks. |
@njuro are you using the latest version? |
I replicated your issue and led me to |
Here is the CSB: https://codesandbox.io/s/suspicious-frog-75c77 RHF is aware of the fields, but they are always undefined. Looks like |
I think I am encountering the same issue with Semantic UI Dropdown. |
Thanks I will investigate the issue soon, in the meantime you could leverage custom register at useffect. React hook from input just some sugar syntax on top. Oh and please provide a codesandbox if u can. |
I think the problem lies in how we get the value from |
I can think of two solutions (maybe @bluebill1049 has better idea):
// outside RHFI component
const handleChange = (e, { checked }) => {
return checked;
}
// inside RHFI component
const handleChange = async (...args) => {
// onChange here is the prop to lift
const data = await onChange(args);
setValue(name, data, isOnChange);
// we can remove this
if (onChange) {
onChange(e);
}
};
const handleChange = (e, props) => {
const data = commonTask(e && e.target ? e.target : isSUI ? props : e);
setValue(name, data, isOnChange);
if (onChange) {
onChange(e);
}
}; |
thanks @JeromeDeLeon why not use |
Oh! Thanks! @bluebill1049 I forgot that one. |
Can we not make it asynchronous? |
@njuro and @raymond-ong , I'l try to provide an example for this and let you know guys. |
what do you mean? |
|
hmm then you need async right? |
and it will always return promise and resolve |
Yes we can await that one. |
Anyway this is beyond the scope of the issue. we'll move this discussion in the spectrum. |
sounds good |
@JeromeDeLeon @bluebill1049 Thanks for the hints guys, I think I figured it out: https://codesandbox.io/s/dazzling-napier-ne3e6 @raymond-ong hope it will solve your issue too |
awesome @njuro! that's what i referred above. |
Thanks @bluebill1049 , the last thing that annoys me is the |
we should fix it, do you have a codesandbox for it? let's patch it. |
@njuro , I mentioned that case above. Sorry, I wasn't able to follow up the example. |
@njuro You can solve it by passing |
Thanks @njuro for the codesandbox and @bluebill1049 for the onChangeEvent suggestion! |
@raymond-ong no worries 👍 guys |
Thanks @JeromeDeLeon now it works perfectly. I already created a little library in my project which wraps Semantic UI form components in RHFInput so I can work with it seamlessly, might publish it as a package once I polish it. |
closing this issue for now :) we can keep the conversation in here :) |
I added |
I investigated: I can cache the event in function handleChange([event]) {
const file = event.target.files[0];
console.log(file);
} But as soon as I try to I made temporary workaround by passing a callback to |
do you have a codesandbox for this? |
@bluebill1049 yes I added it here https://codesandbox.io/s/dazzling-napier-ne3e6 see |
hey @njuro, after some investigation: you will need to use |
@bluebill1049 thanks, can you provide an example please? I am already using onChangeEvent in my codesandbox, but it generates said error |
oh that's right @njuro i will do it today :) |
use this :)
|
@bluebill1049 |
what about |
do you have reference on how semantic UI does it for onChange with input file? |
I have no problem accessing the |
how does semantic UI handle |
worse case you may have to
|
@bluebill1049 Yeah, that's probably the best approach now. Closing this, thanks for you effort :) |
my pleasure :) @njuro 🙏 |
@bluebill1049 I have the same issue. Is there any way to solve this? I cannot use |
Could you please share a codesandbox? also why you probably should consider to use Controller as this component is no longer maintained. |
@bluebill1049 Sorry, I had the following misconception: inputs with a type of file can be controlled, which was cleared by the reactjs docs.
I was trying to solve a problem the wrong way. I just used a hidden input ( Thank you for this great library and for the quick response! Have a good weekend! |
no worries at all 👍 glad it's working out. you have a great weekend too. |
Hello, first of all thanks for your effort creating this library.
Today I have been trying to integrate RHF with components from Semantic UI react library. RHFInput works fine with Form.Input (basic text field), but it fails when I try to wrap Form.Select (https://react.semantic-ui.com/addons/select/) or Form.Checkbox (https://react.semantic-ui.com/modules/checkbox/) with it. I think the reason for this is that Form.Select is not implemented with traditional
<select>
html element, but rather with some<div>
magic and Form.Checkbox also generates some strange "hidden"<input type="checkbox">
element. I believe Semantic UI is fairly popular and used library, so I think it might be worthy to look into this, thank you! Here is the simplified code I am using, nothing is sent when the form is submitted:EDIT:
The checkbox generates following error:
_options$0$ref.attributes is undefined
and also warningWarning: Failed prop type: Invalid prop
valuesupplied to
Checkbox`.And the select generates no error, but the value after submitting is always undefined.
The text was updated successfully, but these errors were encountered: