@@ -1871,6 +1871,69 @@ describe(`AppContainer (dev)`, () => {
1871
1871
expect ( wrapper . update ( ) . text ( ) ) . toBe ( 'PATCHED + 6 v2' )
1872
1872
} )
1873
1873
1874
+ it ( 'hot-reloads children inside simple Fragments' , ( ) => {
1875
+ if ( React . version . startsWith ( '16' ) ) {
1876
+ const unmount = jest . fn ( )
1877
+
1878
+ class InnerComponent extends Component {
1879
+ componentWillUnmount ( ) {
1880
+ unmount ( )
1881
+ }
1882
+
1883
+ render ( ) {
1884
+ return < span > internal</ span >
1885
+ }
1886
+ }
1887
+ InnerComponent . displayName = 'InnerComponent'
1888
+
1889
+ const App = ( ) => (
1890
+ < React . Fragment >
1891
+ < button >
1892
+ text < InnerComponent />
1893
+ </ button >
1894
+ </ React . Fragment >
1895
+ )
1896
+
1897
+ RHL . register ( App , 'App' , 'test.js' )
1898
+
1899
+ const wrapper = mount (
1900
+ < AppContainer >
1901
+ < App />
1902
+ </ AppContainer > ,
1903
+ )
1904
+
1905
+ {
1906
+ class InnerComponent extends Component {
1907
+ componentWillUnmount ( ) {
1908
+ unmount ( )
1909
+ }
1910
+
1911
+ render ( ) {
1912
+ return < span > internal</ span >
1913
+ }
1914
+ }
1915
+ InnerComponent . displayName = 'InnerComponent'
1916
+
1917
+ const App = ( ) => (
1918
+ < React . Fragment >
1919
+ < button >
1920
+ another text< InnerComponent />
1921
+ </ button >
1922
+ </ React . Fragment >
1923
+ )
1924
+ RHL . register ( App , 'App' , 'test.js' )
1925
+
1926
+ wrapper . setProps ( { children : < App /> } )
1927
+ }
1928
+
1929
+ expect ( unmount ) . toHaveBeenCalledTimes ( 0 )
1930
+ expect ( wrapper . update ( ) . text ( ) ) . toBe ( 'another textinternal' )
1931
+ } else {
1932
+ // React 15 is always ok
1933
+ expect ( true ) . toBe ( true )
1934
+ }
1935
+ } )
1936
+
1874
1937
it ( 'hot-reloads children inside Fragments' , ( ) => {
1875
1938
if ( React . version . startsWith ( '16' ) ) {
1876
1939
const unmount = jest . fn ( )
@@ -1904,6 +1967,9 @@ describe(`AppContainer (dev)`, () => {
1904
1967
< InnerItem />
1905
1968
</ li >
1906
1969
< li > 3</ li >
1970
+ < React . Fragment >
1971
+ < span > F</ span >
1972
+ </ React . Fragment >
1907
1973
</ React . Fragment >
1908
1974
)
1909
1975
//
@@ -1920,7 +1986,7 @@ describe(`AppContainer (dev)`, () => {
1920
1986
)
1921
1987
1922
1988
expect ( wrapper . update ( ) . text ( ) ) . toBe (
1923
- '1-1-OldInnerComponent-3-OldInnerComponent3 ' ,
1989
+ '1-1-OldInnerComponent-3-OldInnerComponent3F ' ,
1924
1990
)
1925
1991
{
1926
1992
class InnerComponent extends Component {
@@ -1941,6 +2007,9 @@ describe(`AppContainer (dev)`, () => {
1941
2007
-2-< InnerComponent />
1942
2008
{ false && < div > hole</ div > }
1943
2009
-3-< InnerComponent />
2010
+ < React . Fragment >
2011
+ < span > *</ span >
2012
+ </ React . Fragment >
1944
2013
</ React . Fragment >
1945
2014
)
1946
2015
RHL . register ( InnerItem , 'InnerItem' , 'test.js' )
@@ -1949,7 +2018,7 @@ describe(`AppContainer (dev)`, () => {
1949
2018
}
1950
2019
expect ( unmount ) . toHaveBeenCalledTimes ( 0 )
1951
2020
expect ( wrapper . update ( ) . text ( ) ) . toBe (
1952
- '1-2-NewInnerComponent-3-NewInnerComponent3' ,
2021
+ '1-2-NewInnerComponent-3-NewInnerComponent*3F' , // it should not be so!
1953
2022
)
1954
2023
} else {
1955
2024
// React 15 is always ok
0 commit comments