-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redraw only once when store triggers along with ancestor rerender
- Loading branch information
1 parent
a341ce8
commit af7e043
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/over_react/component_declaration/flux_component_test/nested.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
part of over_react.component_declaration.flux_component_test; | ||
|
||
@Factory() | ||
UiFactory<TestNestedProps> TestNested; | ||
|
||
@Props() | ||
class TestNestedProps extends FluxUiProps {} | ||
|
||
@Component() | ||
class TestNestedComponent extends FluxUiComponent { | ||
int renderCount = 0; | ||
|
||
@override | ||
render() { | ||
renderCount++; | ||
|
||
var keyCounter = 0; | ||
var newChildren = props.children.map((child) { | ||
// The keys are consistent across rerenders, so they aren't remounted, | ||
// but cloning the element is necessary for react to consider it changed, | ||
// since it returns new ReactElement instances. | ||
return cloneElement(child, domProps()..key = keyCounter++); | ||
}).toList(); | ||
|
||
return Dom.div()(newChildren); | ||
} | ||
} |