Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont work with hooks #101

Open
patricklongo1 opened this issue Dec 18, 2019 · 6 comments
Open

dont work with hooks #101

patricklongo1 opened this issue Dec 18, 2019 · 6 comments

Comments

@patricklongo1
Copy link

if u try use hooks.. its do not works.

Ex:
const [price, setPrice] = useState('');

<CurrencyInput
decimalSeparator=","
thousandSeparator="."
prefix="R$ "
onChangeEvent={(event, maskedvalue, floatvalue) =>
setPrice(floatvalue)
}
/>

the input keep reseting...
can someone try fix this?

@colthreepv
Copy link

use also value={price}

Full example:

<CurrencyInput decimalSeparator="," thousandSeparator="." precision="2" suffix=" €"
  value={price}
  selectAllOnFocus
  onChange={(_, val) => setPrice(val)}/>

@patricklongo1
Copy link
Author

use also value={price}

Full example:

<CurrencyInput decimalSeparator="," thousandSeparator="." precision="2" suffix=" €"
  value={price}
  selectAllOnFocus
  onChange={(_, val) => setPrice(val)}/>

Tks man! Its worked for me!

@nazarenooviedo
Copy link

Still not working for me, do you any comment? Thanks

@patricklongo1
Copy link
Author

patricklongo1 commented Jan 14, 2020

Still not working for me, do you any comment? Thanks

My full code for this lib: https://github.com/patricklongo1/gympoint-web/blob/master/src/pages/PlanRegister/index.js

@Important:
import CurrencyInput from 'react-currency-input';
const [priceMonth, setPriceMonth] = useState('');

function handleInput(floatvalue) {
setPriceMonth(floatvalue);
}

return (
< div >
< span >PREÇO MENSAL< /span >
< CurrencyInput
thousandSeparator="."
decimalSeparator=","
precision="2"
prefix="R$ "
value={priceMonth}
selectAllOnFocus
onChange={(_, floatvalue) => handleInput(floatvalue)}
/ >
< /div >
)

Hope its help u!

@nazarenooviedo
Copy link

Thank so much!, I will try it 👍

@ericblade
Copy link

ericblade#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants