mobxjs / mobx-react

React bindings for MobX
https://mobx.js.org/react-integration.html
MIT License
4.85k stars 349 forks source link

Log why function component re-rendered #856

Closed evelant closed 4 years ago

evelant commented 4 years ago

Perhaps I'm missing something obvious here, but I can't seem to find a way to log the reason why a function component wrapped in observer is re-rendering. I tried trace() but it just prints "[mobx.trace] 'observer' tracing enabled" and no further information.

What's the best way to log why a function component is rendering?

mweststrate commented 4 years ago

put the trace at the end of your func. Note that it might also rerender unrelated to mobx, for that you can use the React profiler

On Wed, Apr 29, 2020 at 3:44 PM amorsillo notifications@github.com wrote:

Perhaps I'm missing something obvious here, but I can't seem to find a way to log the reason why a function component wrapped in observer is re-rendering. I tried trace() but it simple prints "[mobx.trace] 'observer' tracing enabled" and no further information.

What's the best way to log why a function component is rendering?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react/issues/856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBHADQGZBTOJZ6JFIR3RPA4LHANCNFSM4MTZCFAQ .

evelant commented 4 years ago

Ah, I made an unrelated mistake causing confusion. trace() works fine. Thanks!