@@ -1613,11 +1613,8 @@ export function attach(
1613
1613
prevFiber : Fiber | null ,
1614
1614
nextFiber : Fiber ,
1615
1615
) : ChangeDescription | null {
1616
- switch ( getElementTypeForFiber ( nextFiber ) ) {
1617
- case ElementTypeClass :
1618
- case ElementTypeFunction :
1619
- case ElementTypeMemo :
1620
- case ElementTypeForwardRef :
1616
+ switch ( nextFiber . tag ) {
1617
+ case ClassComponent :
1621
1618
if ( prevFiber === null ) {
1622
1619
return {
1623
1620
context : null ,
@@ -1640,15 +1637,39 @@ export function attach(
1640
1637
nextFiber . memoizedState ,
1641
1638
) ,
1642
1639
} ;
1643
-
1644
- // Only traverse the hooks list once, depending on what info we're returning.
1640
+ return data ;
1641
+ }
1642
+ case IncompleteFunctionComponent :
1643
+ case FunctionComponent :
1644
+ case IndeterminateComponent :
1645
+ case ForwardRef :
1646
+ case MemoComponent :
1647
+ case SimpleMemoComponent :
1648
+ if ( prevFiber === null ) {
1649
+ return {
1650
+ context : null ,
1651
+ didHooksChange : false ,
1652
+ isFirstMount : true ,
1653
+ props : null ,
1654
+ state : null ,
1655
+ } ;
1656
+ } else {
1645
1657
const indices = getChangedHooksIndices (
1646
1658
prevFiber . memoizedState ,
1647
1659
nextFiber . memoizedState ,
1648
1660
) ;
1649
- data . hooks = indices ;
1650
- data . didHooksChange = indices !== null && indices . length > 0 ;
1651
-
1661
+ const data : ChangeDescription = {
1662
+ context : getContextChangedKeys ( nextFiber ) ,
1663
+ didHooksChange : indices !== null && indices . length > 0 ,
1664
+ isFirstMount : false ,
1665
+ props : getChangedKeys (
1666
+ prevFiber . memoizedProps ,
1667
+ nextFiber . memoizedProps ,
1668
+ ) ,
1669
+ state : null ,
1670
+ hooks : indices ,
1671
+ } ;
1672
+ // Only traverse the hooks list once, depending on what info we're returning.
1652
1673
return data ;
1653
1674
}
1654
1675
default :
@@ -1841,20 +1862,13 @@ export function attach(
1841
1862
1842
1863
const indices = [ ] ;
1843
1864
let index = 0 ;
1844
- if (
1845
- next . hasOwnProperty ( 'baseState' ) &&
1846
- next . hasOwnProperty ( 'memoizedState' ) &&
1847
- next . hasOwnProperty ( 'next' ) &&
1848
- next . hasOwnProperty ( 'queue' )
1849
- ) {
1850
- while ( next !== null ) {
1851
- if ( didStatefulHookChange ( prev , next ) ) {
1852
- indices . push ( index ) ;
1853
- }
1854
- next = next . next ;
1855
- prev = prev . next ;
1856
- index ++ ;
1865
+ while ( next !== null ) {
1866
+ if ( didStatefulHookChange ( prev , next ) ) {
1867
+ indices . push ( index ) ;
1857
1868
}
1869
+ next = next . next ;
1870
+ prev = prev . next ;
1871
+ index ++ ;
1858
1872
}
1859
1873
1860
1874
return indices ;
@@ -1865,16 +1879,6 @@ export function attach(
1865
1879
return null ;
1866
1880
}
1867
1881
1868
- // We can't report anything meaningful for hooks changes.
1869
- if (
1870
- next . hasOwnProperty ( 'baseState' ) &&
1871
- next . hasOwnProperty ( 'memoizedState' ) &&
1872
- next . hasOwnProperty ( 'next' ) &&
1873
- next . hasOwnProperty ( 'queue' )
1874
- ) {
1875
- return null ;
1876
- }
1877
-
1878
1882
const keys = new Set ( [ ...Object . keys ( prev ) , ...Object . keys ( next ) ] ) ;
1879
1883
const changedKeys = [ ] ;
1880
1884
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
0 commit comments