s-yadav / react-number-format

React component to format numbers in an input or as a text.
MIT License
3.9k stars 410 forks source link

customInput with IonInput (Ionic Framework) not triggering onChange nor onValueChange events #737

Open ifigueroap opened 1 year ago

ifigueroap commented 1 year ago

As per the title, customInput with IonInput (Ionic Framework) not triggering onChange nor onValueChange events. I suppose this is because IonInputhas the ionChangeevent rather than plain "change". Is there any way to "remap" this?

A snippet of what I'm trying to achieve, in combination with react hook form:

<Controller
      control={control}
      name="quoteHours"
      render={({ field: { onChange, name, value } }) => (
        <NumericFormat
          name={name}
          value={value}
          customInput={<IonInput />}
          onChange={(e) => {
            console.log("onChange");
            console.log(e);
          }}
          onValueChange={(values, sourceInfo) => {
            console.log("on value change");
            console.log(values);
            console.log(sourceInfo);
            // onChange(values);
          }}
          suffix={"hrs"}
          displayType={"input"}
          allowNegative={false}
          type="text"
        />
      )}
    />
s-yadav commented 1 year ago

Looks like its passed on wrong way. It should be

customInput={IonInput}