insin / react-maskedinput

Masked <input/> React component

Home Page:http://insin.github.io/react-maskedinput/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pass raw value to redux-form

victorsilent opened this issue · comments

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"}
                    />
                  )
                }}
              />

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.

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

You need to use ref to call rawValue

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.