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 React, {useDebugValue, useEffect, useState} from 'react';
    
  11. 
    
  12. export function Component() {
    
  13.   const [count, setCount] = useState(0);
    
  14.   const isDarkMode = useIsDarkMode();
    
  15.   const {foo} = useFoo();
    
  16. 
    
  17.   useEffect(() => {
    
  18.     // ...
    
  19.   }, []);
    
  20. 
    
  21.   const handleClick = () => setCount(count + 1);
    
  22. 
    
  23.   return (
    
  24.     <>
    
  25.       <div>Dark mode? {isDarkMode}</div>
    
  26.       <div>Count: {count}</div>
    
  27.       <div>Foo: {foo}</div>
    
  28.       <button onClick={handleClick}>Update count</button>
    
  29.     </>
    
  30.   );
    
  31. }
    
  32. 
    
  33. function useIsDarkMode() {
    
  34.   const [isDarkMode] = useState(false);
    
  35. 
    
  36.   useEffect(function useEffectCreate() {
    
  37.     // Here is where we may listen to a "theme" event...
    
  38.   }, []);
    
  39. 
    
  40.   return isDarkMode;
    
  41. }
    
  42. 
    
  43. function useFoo() {
    
  44.   useDebugValue('foo');
    
  45.   return {foo: true};
    
  46. }