File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " rax" ,
3
- "version" : " 1.1.3 " ,
3
+ "version" : " 1.1.4 " ,
4
4
"description" : " A universal React-compatible render engine." ,
5
5
"license" : " BSD-3-Clause" ,
6
6
"main" : " index.js" ,
Original file line number Diff line number Diff line change @@ -66,12 +66,24 @@ describe('render', () => {
66
66
expect ( instance1 === instance2 ) . toBe ( true ) ;
67
67
} ) ;
68
68
69
- it ( 'should reuse markup if rendering to the same target twice' , function ( ) {
69
+ it ( 'should trigger afterRender twice when render to the same target twice' , ( ) => {
70
+ let beforeRenderCount = 0 ;
71
+ let afterRenderCount = 0 ;
70
72
let container = createNodeElement ( 'container' ) ;
71
- let instance1 = render ( < div /> , container ) ;
72
- let instance2 = render ( < div /> , container ) ;
73
+ Host . driver = Object . assign ( { } , Host . driver , {
74
+ beforeRender ( ) {
75
+ beforeRenderCount += 1 ;
76
+ } ,
77
+ afterRender ( ) {
78
+ afterRenderCount += 1 ;
79
+ } ,
80
+ } ) ;
73
81
74
- expect ( instance1 === instance2 ) . toBe ( true ) ;
82
+ render ( < div /> , container ) ;
83
+ render ( < span /> , container ) ;
84
+
85
+ expect ( beforeRenderCount ) . toBe ( 2 ) ;
86
+ expect ( afterRenderCount ) . toBe ( 2 ) ;
75
87
} ) ;
76
88
77
89
it ( 'should not throw error when have callback and options is null' , function ( done ) {
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ export default {
70
70
prevRootInstance [ INTERNAL ] . __penddingContext = parentContext ;
71
71
}
72
72
prevRootInstance . __update ( element ) ;
73
+
74
+ // After render callback
75
+ driver . afterRender && driver . afterRender ( renderOptions ) ;
76
+
73
77
return prevRootInstance ;
74
78
}
75
79
@@ -78,6 +82,7 @@ export default {
78
82
let defaultContext = parentContext || { } ;
79
83
let rootInstance = renderedComponent . __mountComponent ( container , parent , defaultContext ) ;
80
84
this . set ( container , rootInstance ) ;
85
+
81
86
// Mount new element through update queue avoid when there is in rendering phase
82
87
rootInstance . __update ( element ) ;
83
88
@@ -87,7 +92,6 @@ export default {
87
92
if ( process . env . NODE_ENV !== 'production' ) {
88
93
// Devtool render new root hook
89
94
Host . reconciler . renderNewRootComponent ( rootInstance [ INTERNAL ] [ RENDERED_COMPONENT ] ) ;
90
-
91
95
Host . measurer && Host . measurer . afterRender ( ) ;
92
96
}
93
97
You can’t perform that action at this time.
0 commit comments