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

feat: Add source details in onValueChange #591

Merged
merged 4 commits into from
Nov 8, 2021
Merged

Conversation

nikhil-varma
Copy link
Collaborator

@nikhil-varma nikhil-varma commented Nov 7, 2021

Describe the issue/change

This PR adds a source object in the onValueChange function which returns the event object and the source of the trigger

Describe the changes proposed/implemented in this PR

API change for onValueChange to allow getting the source details and the event object

Link Github issue if this PR solved an existing issue

Issue: #587

Example usage (If applicable)

<NumberFormat
  value={this.state.profit}
  thousandSeparator={true}
  prefix={'$'}
  onValueChange={(values, sourceInfo) => {
    const { formattedValue, value } = values;
    // Event is a Synthetic Event wrapper which holds target and other information. Source tells whether the reason for this function being triggered was an 'event' or due to a 'prop' change
    const { event, source } = sourceInfo;
  }}

Screenshot (If applicable)#### Please check which browsers were used for testing

  • Chrome
  • Chrome (Android)
  • Safari (OSX)
  • Safari (iOS)
  • Firefox
  • Firefox (Android)

@nikhil-varma nikhil-varma self-assigned this Nov 8, 2021
@nikhil-varma nikhil-varma marked this pull request as ready for review November 8, 2021 17:47
@nikhil-varma
Copy link
Collaborator Author

@s-yadav API changes are done. Any suggestions on what kind of documentation examples we can add? I think we can give more details. What do you say?

@nikhil-varma nikhil-varma requested a review from s-yadav November 8, 2021 17:48
@nikhil-varma nikhil-varma changed the base branch from master to develop November 8, 2021 18:02
@nikhil-varma nikhil-varma changed the base branch from develop to dev November 8, 2021 18:07
@nikhil-varma nikhil-varma merged commit 1a70575 into dev Nov 8, 2021
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.

Listen to input changes event only, while retaining access to the raw values in the callback
2 participants