Skip to content

Refactored: added default values in params for ReferenceArea and ReferenceLine since default props is deprecated#3283

Merged
ckifer merged 2 commits into
recharts:masterfrom
aushwin:refactor/defaultProps_referenceArea_and_referenceLine
Jan 26, 2023
Merged

Refactored: added default values in params for ReferenceArea and ReferenceLine since default props is deprecated#3283
ckifer merged 2 commits into
recharts:masterfrom
aushwin:refactor/defaultProps_referenceArea_and_referenceLine

Conversation

@aushwin

@aushwin aushwin commented Jan 26, 2023

Copy link
Copy Markdown
Contributor
  • updated ReferenceArea
  • updated ReferenceLine

Description

Have destructed the props in the params added the value and combined them into a prop object so that it can be passed down to other functions with the default value.

Related Issue

#3278

Motivation and Context

Since defaultProps is deprecated, we would avoid future potential warnings/errors

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…ecated

- updated ReferenceArea
- updated ReferenceLine

@ckifer ckifer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 - thanks!


export function ReferenceArea(props: Props) {
export function ReferenceArea({
isFront = false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destructuring props here doesn't really do anything for us if they're just added back into the props object below. I guess a future refactor can be to use the destructured values directly where possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will work on this and the build failing issue

@aushwin aushwin Jan 26, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ckifer
only when am destructuring the xAxis and yAxis are becoming undefined . Any reason why this is happening
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably because 0 is falsy, but not sure

@ckifer ckifer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like build is failing

@aushwin
aushwin requested a review from ckifer January 26, 2023 21:34

@ckifer ckifer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine as an initial refactor, we can come back to it if we need. Thanks @aushwin

@ckifer

ckifer commented Mar 14, 2023

Copy link
Copy Markdown
Member

Hey @aushwin

Sorry to say but I'm going to have to revert this change. Please see #3438

ckifer pushed a commit to ckifer/recharts that referenced this pull request Mar 14, 2023
…and ReferenceLine since default props is deprecated (recharts#3283)"

This reverts commit ea13805.
ckifer pushed a commit to ckifer/recharts that referenced this pull request Mar 14, 2023
…and ReferenceLine since default props is deprecated (recharts#3283)"

This reverts commit ea13805.
ckifer added a commit that referenced this pull request Mar 14, 2023
…nd ReferenceLine since default props is deprecated (#3455)

…(#3283)"

This reverts commit ea13805.

<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

See comment here
#3438 (comment)

Basically recharts breaks down without defaultProps because it
references props set by defaultProps _outside_ of said component
(antipattern alert 🚫) before the components are initialized/invoked.
Default parameters do not get set until the component is run - before
that function components only have reference to the props sent by the
user.

This will be a huge undertaking to fix. For now revert the change.

Two other small changes with this revert:
* fixed annoying eslint issue
* added storybook test 

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->
#3438

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
bug introduced in 2.4.x

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
* existing tests pass
* run on storybook
   * settings are now set correctly
   * add storybook test

## Screenshots (if appropriate):

![image](https://user-images.githubusercontent.com/25180830/224912521-7a73da23-87ec-434a-9236-f8a739705b90.png)


## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.

Co-authored-by: Coltin Kifer <[email protected]>
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