Confused by formatting inputs example on home page

Open
#108 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, react-native
Domain
documentation

Research direction

Review the linked Formatting Inputs example and the shown formatPhoneNumber line. Clarify what the function syntax means, how spaces are added, and how the value prop is handled; it is done when the example answers the reporter’s questions directly.

Written by the indexing model from the issue text.

Description

In this example Formatting Inputs I'm confused by this line:

const formatPhoneNumber: string => string = (unformattedPhoneNumber) => ...;

Why the double function indirection? How exactly is that adding spaces? I'm guessing it's just a sample to say that if "value" prop is a function, it'll get called but store the value untransformed.

Would love some hints.

Dominant language
JavaScript
Stars
398
Forks
50
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bamlab/react-native-formik

All issues in bamlab/react-native-formik

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.