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

[Question] ability to add to all components? #32

Closed
justinhelmer opened this issue May 14, 2019 · 11 comments
Closed

[Question] ability to add to all components? #32

justinhelmer opened this issue May 14, 2019 · 11 comments

Comments

@justinhelmer
Copy link

First, thanks for such an amazing tool with hooks support. Incredibly helpful.

We have over 100 components in our project, and it will take a long time to manually add Component.whyDidYouRender = true; in every single file.

Is there a way to attach to everything? I see the [include] option, but we are currently not using DisplayName - so we would still have to touch every file.

Thanks for the help.

@vzaidman
Copy link
Collaborator

what would you like to use to decide if a component should be tracked?

https://github.com/welldone-software/why-did-you-render/blob/master/src/shouldTrack.js

here is the file that makes this decision

@justinhelmer
Copy link
Author

justinhelmer commented May 15, 2019

Thanks for the quick reply. I suppose I'm suggesting something along these lines:

return !!(
  options.includeAll ||
  Component.whyDidYouRender ||
  shouldInclude(displayName, options)
)

@vzaidman
Copy link
Collaborator

try include: [/.*/].

what do you say?

@justinhelmer
Copy link
Author

justinhelmer commented May 16, 2019

works like a charm, thanks.

Closing

@zhangenming
Copy link

so why not provide a option?
such as

const whyDidYouRender = require('@welldone-software/why-did-you-render')
whyDidYouRender.isTrackAllPureComponent = true //default can be false
whyDidYouRender(React)

@vzaidman
Copy link
Collaborator

i don't want people to track all components. it's not a best practice.
if you want to do it, use include: [/.*/]

@zhangenming
Copy link

i don't want people to track all components. it's not a best practice.
if you want to do it, use include: [/.*/]

i dont very familiar about react
how about just track all component that implement SCU (or PureComponent )
thanks

@vzaidman
Copy link
Collaborator

that's a good idea. ill consider it

@vzaidman
Copy link
Collaborator

implement SCU?

@zhangenming
Copy link

scu: shouldComponentUpdate

@vzaidman
Copy link
Collaborator

ok ill add this configuration. thanks for the idea

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

No branches or pull requests

3 participants