npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

expo-toast

v1.0.3

Published

React Native toast component, It works on Android iOS and Expo

Readme

expo-toast

react-native搞了这么多年,没有一个既简单又实用的toast

不是过了好多年没人维护,各种报错,就是issues已读不关,再就是props封装的乱七八糟。

那么问题来了,react-native的大旗谁来扛?

一行代码直接梭哈 ...

const toast = useToast();
toast.show("HelloWorld.");

什么?想自定义样式?

完全原生的样式,会ViewText,就会自定义样式。

原理

本质上就是在根节点注入一个View,和所有的页面同一级,然后想办法在子页面的任何地方都能显示这个View

DeviceEmitter

设备监听,这个是最直接,感觉也是最傻的方法。因为要监听一个事件,就要每次发消息,所以发消息还要再做一次封装。性能有没有问题不知道,太菜了。

Provider

这也就是这个库用的方式,像很多的状态管理库,都是根节点注入SomeStoreProvider,然后全局任何地方都能访问这个store

所以这也就是我换了个思路,搞了一个ToastProvider

使用

在项目的入口,注入ToastProvider

  • react-native

    • /index.js
  • expo

    • /app/_layout.tsx
import { ToastProvider } from "expo-toast";
return (
  <ToastProvider>
    {/* ... Other Provider */}
    {/* App.tsx */}
    {/* ... */}
  </ToastProvider>
);

不足之处

  • 多个消息的队列处理,像antdtoast一样,可以以队列的形式,一直叠加展示。

  • 要自己写waringsuccessinfo的样式,不过这也不重要,自己再封装一下,options里面丢几个颜色进去就好(:手动吃瓜)。

Props

没啥好介绍的:

position

位置,POSITION.POSITOP | POSITION.BOTTON

duration

毫秒数,想弹多久弹多久。

containerStyle

样式,和View的样式一样,用的就是ViewStyle

textStyle

内容样式,和Text的样式一样,用的就是TextStyle