insin / react-maskedinput

Masked <input/> React component
http://insin.github.io/react-maskedinput/
MIT License
730 stars 197 forks source link

Pass raw value to redux-form #129

Open victorsilent opened 6 years ago

victorsilent commented 6 years ago

Hello, I'm using that lib with material-ui and redux-form, so, actually I've passed the mask to redux-form, but only with mask, I saw that could be handle with ref.mask.getRawValue, so, how can I call that function to redux-form get raw value?


             <Field
                name="documentation.cpf"
                labelText="CPF"
                id="documentation.cpf"
                component={CustomInputRedux}
                InputProps={{
                  inputComponent: other => (
                    <MaskedInput
                      ref={this.cpfRef}
                      {...other}
                      mask={"111.111.111-11"}
                      placeholderChar={"\u2000"}
                    />
                  )
                }}
              />
vaske commented 5 years ago

In onChage you can access to raw value like

onChange={(e) => {
   console.log(e.target.rawValue);
   }
}

and then I guess you may assign this to redux-form or add wrapped function to do it for you.

wemersonrv commented 5 years ago

Hi, i'm trying to use rawValue but not works.

<MaskedInput 
  name="cnpj" type="text" value={inputValue}
  onChange={(e) => {
    console.log(e.target.rawValue);
  }}
  mask="11.111.111/1111-11"
/>

The result is undefined

victorsilent commented 5 years ago

You need to use ref to call rawValue

nfantone commented 4 years ago

This doesn't seem to work anymore. Using a ref, mask.getValue() and mask.getRawValue() return the exact same value for me. And target.rawValue is now absent from the synthetic event.