welldone-software/why-did-you-render

Show line where hook that changed is used (feature request)

Open

#191 建立於 2021年4月27日

在 GitHub 查看
 (3 留言) (4 反應) (0 負責人)JavaScript (10,560 star) (188 fork)batch import
enhancementgood first issuehelp wanted

描述

I currently have a very big hook, with dozens of useStates, lots of them have empty arrays which trigger unncesary re-renders. But I don't know which is the one doing it each time wdyr logs it's output. I get:

Re-rendered because of hook changes: 
[hook useState result]
...diff

When would be very useful for me is:

Re-rendered because of hook changes:
[hook useState result] (someRandomHook.ts:34)
...diff

Knowing which hook is changing would be useful, specially in nested hooks scenarios, for example I have a hook which uses a hook, and that internal one has state, but wdyr does not even specify which hook is that useState from (I guess react makes no distinction, it only cares about hook declaration order, so not sure how possible would this feature request be.)

貢獻者指南