Skip to content

Commit fcc630f

Browse files
authored
docs: add formatting input example
1 parent f63433d commit fcc630f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This repository is a set of high order components designed to help you take cont
1616

1717
- [Installation](#installation)
1818
- [Advanced Example](#advanced-example)
19+
- [Formatting inputs](#formatting-inputs)
1920
- [API](#api)
2021
- [makeReactNativeField](#makereactnativefield)
2122
- [setFormikInitialValue](#setFormikInitialValue)
@@ -185,6 +186,27 @@ export default props => (
185186
);
186187
```
187188

189+
## Formatting inputs
190+
191+
You may need to format inputs as the user types in. For instance, adding spaces in a telephone number (`0612345678` -> `06 12 34 56 78`).
192+
Here's how you would do it:
193+
194+
```javascript
195+
const formatPhoneNumber: string => string = (unformattedPhoneNumber) => ...;
196+
197+
...
198+
199+
<Formik
200+
render={({ values }) => {
201+
return (
202+
<Form>
203+
<MyInput name="phoneNumber" value={formatPhoneNumber(values.phoneNumber)} />
204+
</Form>
205+
);
206+
}}
207+
/>
208+
```
209+
188210
## API
189211

190212
### makeReactNativeField

0 commit comments

Comments
 (0)