welldone-software/why-did-you-render

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

開放

#191 建立於 2021年4月27日

 (3 則留言) (4 個反應) (0 位負責人)JavaScript (188 個分叉)batch import
enhancementgood first issuehelp wanted

倉庫指標

星標
 (10,560 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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.)

貢獻者指南