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

[DevTools] Implemented re-render mechanism for React 16.9+ #17072

Closed

Conversation

hristo-kanchev
Copy link
Contributor

@hristo-kanchev hristo-kanchev commented Oct 12, 2019

Solves: #16968

Description:
Added force re-render mechanism for components.

Support:
As @bvaughn suggested, we will only support React 16.9+
Versions that aren't supported won't show the re-render button in the UI.

Tested on:

  • Versions that are < 16.9 do not show the re-render button in the UI.
  • Versions that are >= 16.9 show the re-render button in the UI and successfully dispatch an update to the supported components types.

re-render

@sizebot
Copy link

sizebot commented Oct 12, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS against 271518f

@hristo-kanchev hristo-kanchev changed the title feat: Implemented re-render mechanism for React 16.9+ [DevTools] Implemented re-render mechanism for React 16.9+ Oct 12, 2019
const fiber = findCurrentFiberUsingSlowPathById(id);

if (fiber !== null) {
if (typeof scheduleUpdate === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this line be merged with the line above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! I've pushed the changes.

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

The code seems solid.

Forced updates confuse the profiler- (it shows a commit with no updated components) but I don't think that's really a problem 😄

@@ -125,6 +125,7 @@ export default class Agent extends EventEmitter<{|
bridge.addListener('getOwnersList', this.getOwnersList);
bridge.addListener('inspectElement', this.inspectElement);
bridge.addListener('logElementToConsole', this.logElementToConsole);
bridge.addListener('forceRerender', this.forceRerender);
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit: Maybe just "forceRender" ? The "re" seems unnecessary.

@bvaughn
Copy link
Contributor

bvaughn commented Oct 14, 2019

I think we could improve the UX a bit though. When you click the button, there's no confirmation or signal that it's actually been clicked. Nothing happens.

Maybe we need to make it stay highlighted for a second :think: or something. Thoughts?

@bvaughn
Copy link
Contributor

bvaughn commented Oct 14, 2019

I guess I still don't quite understand the use case of this feature, so I'd like to hold off merging it for the time being until I understand it better, and we work out the UX issue.

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

Removing approval for now.

@@ -2247,6 +2253,9 @@ export function attach(
// Can view component source location.
canViewSource,

// Can force the component to re-render.
canForceRerender,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be conditional based on the element type. Right now it shows up for all types, including e.g. context providers and consumers, etc- re-rendering these doesn't make sense. Seems like this should be for class, function, forward ref, and maybe memo components types only?

@hristo-kanchev
Copy link
Contributor Author

hristo-kanchev commented Oct 14, 2019

Heya @bvaughn ! I'll address your comments and after that we can park it for the time being, until we get more feature requests like this one? What do you think?

@bvaughn
Copy link
Contributor

bvaughn commented Oct 14, 2019

Sounds good, and thanks for being so understanding.

The code approach here seems fine. I'm just not sure the feature itself makes total sense yet, until I better understand the use case :)

@bvaughn
Copy link
Contributor

bvaughn commented Oct 28, 2019

We chatted on #16968 and agreed to close this for now.

Thanks a bunch for the PR though!

@bvaughn bvaughn closed this Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants