@amazon-devices/react-native-masked-view__masked-view

中文文档
2.0.9000000003发布于 2026/10/30See license in LICENSETypeScriptCommonJS零依赖近 30 天下载 3828

React Native MaskedView component

原始使用文档
文档目录9 节
  1. Platforms Supported
  2. Getting Started
  3. Using React Native >= 0.60
  4. Using React Native < 0.60
  5. Usage
  6. Props
  7. Reference
  8. maskElement
  9. androidRenderingMode

React Native MaskedView

Build Status Version MIT License Lean Core Badge

Provides a React component that renders a masked view.

Platforms Supported

  • iOS
  • Android
  • Web

Getting Started

yarn add @react-native-masked-view/masked-view

or

npm install --save @react-native-masked-view/masked-view

Using React Native >= 0.60

Linking the package manually is not required anymore with Autolinking.

Remember to install the pod with:

npx pod-install

Using React Native < 0.60

You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:

react-native link @react-native-masked-view/masked-view

Usage

Import the MaskedView component from @react-native-masked-view/masked-view and use it like so:

import React from 'react';
import { Text, View } from 'react-native';
import MaskedView from '@react-native-masked-view/masked-view';

const App = () => {
  return (
    <MaskedView
      style={{ flex: 1, flexDirection: 'row', height: '100%' }}
      maskElement={
        <View
          style={{
            // Transparent background because mask is based off alpha channel.
            backgroundColor: 'transparent',
            flex: 1,
            justifyContent: 'center',
            alignItems: 'center',
          }}
        >
          <Text
            style={{
              fontSize: 60,
              color: 'black',
              fontWeight: 'bold',
            }}
          >
            Basic Mask
          </Text>
        </View>
      }
    >
      {/* Shows behind the mask, you can put anything here, such as an image */}
      <View style={{ flex: 1, height: '100%', backgroundColor: '#324376' }} />
      <View style={{ flex: 1, height: '100%', backgroundColor: '#F5DD90' }} />
      <View style={{ flex: 1, height: '100%', backgroundColor: '#F76C5E' }} />
      <View style={{ flex: 1, height: '100%', backgroundColor: '#e1e1e1' }} />
    </MaskedView>
  );
}

export default App

The following image demonstrates that you can put almost anything behind the mask. The three examples shown are masked <View>, <Text>, and <Image>.

Props

Reference

maskElement

TypeRequired
elementYes

androidRenderingMode

By default hardware rendering mode will be used for best performance, however if you need to animate your maskElement then you’ll need to switch to software to get your mask to update. This prop only affects Android.

TypeRequiredDefault
software, hardwareNohardware

版本与发布记录

@amazon-devices/react-native-masked-view__masked-view 共发布 7 个版本,首次发布于 2025/09/25;过去 12 个月发布了 5 个版本。

版本发布日期距今
2.0.9000000003latest2026/10/309 天前
2.0.90000000022026/08/073 个月前
2.0.9000000002-rn-83rn83-alpha2026/06/244 个月前
2.0.90000000002026/06/184 个月前
2.0.9000000000-rn-832026/06/134 个月前
2.0.17591359702025/09/301.1 年前

关于 @amazon-devices/react-native-masked-view__masked-view 的常见问题

@amazon-devices/react-native-masked-view__masked-view 是什么?

React Native MaskedView component

如何安装 @amazon-devices/react-native-masked-view__masked-view?

在项目目录运行 npm install @amazon-devices/react-native-masked-view__masked-view,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)、@amazon-devices/react-native-kepler(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amazon-devices/react-native-masked-view__masked-view 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amazon-devices/react-native-masked-view__masked-view 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amazon-devices/react-native-masked-view__masked-view 可以商用吗?

@amazon-devices/react-native-masked-view__masked-view 使用 See license in LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@amazon-devices/react-native-masked-view__masked-view 的下载量有多少?

根据 npm 官方下载统计,@amazon-devices/react-native-masked-view__masked-view 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,828 次,日均约 128 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amazon-devices/react-native-masked-view__masked-view 还在维护吗?

最新版本 2.0.9000000003 发布于 2026/10/30(9 天前);至今共发布 7 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。