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

Refactor SpanGraph.UNSAFE_componentWillReceiveProps #613

Conversation

tklever
Copy link
Contributor

@tklever tklever commented Aug 11, 2020

Which problem is this PR solving?

Short description of the changes

  • Using component state for memoization is considered a react anti-pattern. By removing it, not only is the size and complexity of the component reduced, but it enables the removal of the legacy method UNSAFE_componentWillReceiveProps

@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #613 into master will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #613      +/-   ##
==========================================
+ Coverage   92.78%   92.84%   +0.06%     
==========================================
  Files         227      227              
  Lines        5908     5902       -6     
  Branches     1490     1487       -3     
==========================================
- Hits         5482     5480       -2     
+ Misses        385      381       -4     
  Partials       41       41              
Impacted Files Coverage Δ
...ents/TracePage/TracePageHeader/SpanGraph/index.tsx 90.90% <100.00%> (+20.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 122a59e...4844d1c. Read the comment docs.

@tklever tklever force-pushed the refactor-UNSAFE-componentWillRecieveProps-spangraph branch from 7ddb539 to 666e07b Compare August 12, 2020 21:14
@rubenvp8510
Copy link
Collaborator

This looks good, +1 on the memoization!

This test codifies the sentiments on SpanGraph/index.tsx#L35, confirming that canvas graph is not re-rendered unless trace is changed

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>
Using component state in this manner is considered a react anti-pattern. By removing it, not only is the size and complexity of the component reduced, but it enables the removal of the legacy method UNSAFE_componentWillReceiveProps

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>
@tklever tklever force-pushed the refactor-UNSAFE-componentWillRecieveProps-spangraph branch from 666e07b to 4844d1c Compare August 17, 2020 17:45

export default class SpanGraph extends React.PureComponent<SpanGraphProps> {
Copy link
Member

@yurishkuro yurishkuro Aug 17, 2020

Choose a reason for hiding this comment

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

React.PureComponent<SpanGraphProps>

IsSpanGraphProps still relevant? Seems like it was only affecting constructor/callback.

Copy link
Member

Choose a reason for hiding this comment

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

ah, I guess it affects this.props in render()

@yurishkuro yurishkuro changed the title Refactor unsafe component will receive props in spangraph Refactor SpanGraph.UNSAFE_componentWillReceiveProps Aug 17, 2020
@yurishkuro yurishkuro merged commit 6843b03 into jaegertracing:master Aug 17, 2020
@tklever tklever deleted the refactor-UNSAFE-componentWillRecieveProps-spangraph branch August 23, 2020 06:31
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 4, 2021
* add test to ensure canvas graph rendering is limited

This test codifies the sentiments on SpanGraph/index.tsx#L35, confirming that canvas graph is not re-rendered unless trace is changed

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>

* refactor SpanGraph to not use internal state for memoization

Using component state in this manner is considered a react anti-pattern. By removing it, not only is the size and complexity of the component reduced, but it enables the removal of the legacy method UNSAFE_componentWillReceiveProps

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 4, 2021
* add test to ensure canvas graph rendering is limited

This test codifies the sentiments on SpanGraph/index.tsx#L35, confirming that canvas graph is not re-rendered unless trace is changed

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>

* refactor SpanGraph to not use internal state for memoization

Using component state in this manner is considered a react anti-pattern. By removing it, not only is the size and complexity of the component reduced, but it enables the removal of the legacy method UNSAFE_componentWillReceiveProps

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 5, 2021
* add test to ensure canvas graph rendering is limited

This test codifies the sentiments on SpanGraph/index.tsx#L35, confirming that canvas graph is not re-rendered unless trace is changed

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>

* refactor SpanGraph to not use internal state for memoization

Using component state in this manner is considered a react anti-pattern. By removing it, not only is the size and complexity of the component reduced, but it enables the removal of the legacy method UNSAFE_componentWillReceiveProps

Signed-off-by: Tim Klever <Tim.V.Klever@aexp.com>
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
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.

None yet

3 participants