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. export function useSyncExternalStore<T>(
    
  11.   subscribe: (() => void) => () => void,
    
  12.   getSnapshot: () => T,
    
  13.   getServerSnapshot?: () => T,
    
  14. ): T {
    
  15.   // Note: The shim does not use getServerSnapshot, because pre-18 versions of
    
  16.   // React do not expose a way to check if we're hydrating. So users of the shim
    
  17.   // will need to track that themselves and return the correct value
    
  18.   // from `getSnapshot`.
    
  19.   return getSnapshot();
    
  20. }