DioxusLabs / DioxusLabs/dioxus

Add "why" a component re-rendered.

Open
#475 0 comments 11 reactions 0 assignees View on GitHub
core
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

## Specific Demand

React has a monkey patch called why-did-you-render. It's mostly used for debugging, but in theory, it could be used to write more efficient hooks.

https://github.com/welldone-software/why-did-you-render

For example, a component could know that it's being re-rendered because it's actively being mounted, it was forced to by a hook, or a parent was diffed causing a diff of the current component.

## Implement Suggestion

Add a new method to "Scope" that includes reasoning of why a component is being re-rendered.

An enum along the lines of:

```rust
enum WhyDidYouRender {
// A distant parent is causing a partial reflow of the tree
Parent { originator: ScopeId },

// The component is being mounted for the first time
Mount,

// A hook or external force directly called this component to be re-rendered
Explicit
}
```

This would be a relatively low-effort addition but could unlock better debugging and more efficient hooks and components.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.