1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. import * as React from 'react';
    
  11. import {useContext} from 'react';
    
  12. import {StoreContext} from '../context';
    
  13. import {
    
  14.   ComponentFilterElementType,
    
  15.   ElementTypeSuspense,
    
  16. } from 'react-devtools-shared/src/frontend/types';
    
  17. 
    
  18. export default function CannotSuspendWarningMessage(): React.Node {
    
  19.   const store = useContext(StoreContext);
    
  20.   const areSuspenseElementsHidden = !!store.componentFilters.find(
    
  21.     filter =>
    
  22.       filter.type === ComponentFilterElementType &&
    
  23.       filter.value === ElementTypeSuspense &&
    
  24.       filter.isEnabled,
    
  25.   );
    
  26. 
    
  27.   // Has the user filtered out Suspense nodes from the tree?
    
  28.   // If so, the selected element might actually be in a Suspense tree after all.
    
  29.   if (areSuspenseElementsHidden) {
    
  30.     return (
    
  31.       <div>
    
  32.         Suspended state cannot be toggled while Suspense components are hidden.
    
  33.         Disable the filter and try again.
    
  34.       </div>
    
  35.     );
    
  36.   } else {
    
  37.     return (
    
  38.       <div>
    
  39.         The selected element is not within a Suspense container. Suspending it
    
  40.         would cause an error.
    
  41.       </div>
    
  42.     );
    
  43.   }
    
  44. }