View.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Copyright (c) Facebook, Inc. and its 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. * @format
  8. * @flow strict-local
  9. */
  10. 'use strict';
  11. import type {ViewProps} from './ViewPropTypes';
  12. const React = require('react');
  13. import ViewNativeComponent from './ViewNativeComponent';
  14. const TextAncestor = require('../../Text/TextAncestor');
  15. export type Props = ViewProps;
  16. /**
  17. * The most fundamental component for building a UI, View is a container that
  18. * supports layout with flexbox, style, some touch handling, and accessibility
  19. * controls.
  20. *
  21. * @see https://reactnative.dev/docs/view.html
  22. */
  23. const View: React.AbstractComponent<
  24. ViewProps,
  25. React.ElementRef<typeof ViewNativeComponent>,
  26. > = React.forwardRef((props: ViewProps, forwardedRef) => {
  27. return (
  28. <TextAncestor.Provider value={false}>
  29. <ViewNativeComponent {...props} ref={forwardedRef} />
  30. </TextAncestor.Provider>
  31. );
  32. });
  33. View.displayName = 'View';
  34. module.exports = View;