Problem with default value doesnt override mask, but add this value to end mask
jerryk1925 opened this issue · comments
Ruslan Himiranov commented
i have this code
import { PatternFormat } from "react-number-format";
export default function App() {
return (
<div className="App">
<h3>
Demo for <code>format</code>
</h3>
<p>
<PatternFormat
type="tel"
allowEmptyFormatting
mask="_"
displayType="input"
value={380991231231}
format="+38 0## ### ## ##"
/>
</p>
</div>
);
}
In screen you can see uncorrect value, how i can fix this problem ?
Sudhanshu Yadav commented
Hey @jerryk1925, Looks like you are passing format numbers as well, as part of value.
The value prop accept three type of values
- Number: In this the number should have format characters, so basically the value you are passing should be just
value={991231231}
- NumericString: In this case as well, it shouldn't contain format character, but you can pass something like
value="991231231"
- FormattedString: In this case it should be full formatted string, something like
value="+38 099 123 12 31"
Based on your requirement you can choose which type of value you are passing.