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

Align Docs Is Allowed Example With Type Definition #546

Conversation

alexanderdavide
Copy link
Contributor

@alexanderdavide alexanderdavide commented May 30, 2021

Describe the issue/change

The docs show a wrong example of the isAllowed callback. It returns the inputObj if it passes the check or undefined. This actually works in JavaScript because of type coercion (IMO still a bad practice). However, in TypeScript the type definition enforces a boolean to be returned.

const MAX_VAL = 1400;
const withValueLimit = (inputObj) => {
  const { value } = inputObj;
  if (value < MAX_VAL) return inputObj;
};
<NumberFormat value={12} isAllowed={withValueLimit} />;

The type definition requires a boolean:

isAllowed?: (values: NumberFormatValues) => boolean;

Describe the changes proposed/implemented in this PR

Aligned the isAllowed example in the docs with the method's type definition.

README.md Outdated Show resolved Hide resolved
@alexanderdavide alexanderdavide changed the title chore: align docs is allowed example with type definition Align Docs Is Allowed Example With Type Definition Jun 3, 2021
@nikhil-varma nikhil-varma dismissed their stale review June 6, 2021 18:25

Changes implemented

@nikhil-varma
Copy link
Collaborator

@alexanderdavide Merging this PR

@nikhil-varma nikhil-varma merged commit a20d18e into s-yadav:master Jun 6, 2021
@alexanderdavide alexanderdavide deleted the chore/align-docs-is-allowed-example-with-type-definition branch June 6, 2021 18:29
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

Successfully merging this pull request may close these issues.

2 participants