百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-portal

> 前端框架
开源

一个简化的门户实现,适用于 ⭕️ React Native 和 Web ⭕️。

790 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个简化的门户实现,适用于 ⭕️ React Native 和 Web ⭕️。

React Native 门户

一个简化的门户实现 ⭕️ React Native ⭕️。

特性

  • 多门户处理。
  • 多门户主机处理。
  • 允许覆盖功能。
  • 与 React Native Web 兼容。
  • 与 Expo 兼容,请查看项目 Expo Snack(https://snack.expo.io/@gorhom/portal-example)。
  • 以 TypeScript 格式写入。

安装

bash
yarn add @gorhom/portal

使用方法

简单门户

这是该库的非常简单的使用方式,您将将内容传送到应用程序的 PortalProvider 层。 首先,您需要在根组件(通常是 App.tsx)中添加 PortalProvider。

typescript
export const App = () => (
  
  {... your app goes here}
  
);

最后,您使用 Portal 将要传送的内容进行包装。

typescript
const BasicScreen = () => {
  return (
    { ... }
    
      
        Text to be teleported to the root host
      
    
    { ... }
  );
};
``` ### 自定义门户主机 当您需要在应用的任何层级将内容传送到自定义门户主机 `PortalHost` 时,请执行以下操作:

```tsx
导入 { FullWindowOverlay } 从 'React-native-screens';
const BasicScreen = () => {
return (
{ … }

[](https://www.npmjs.com/package/@gorhom/portal) [](https://www.npmjs.com/package/@gorhom/portal) [](https://snack.expo.io/@gorhom/portal-example)

Issues· 33 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptportalreactreact-native

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架