Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
react-native-fast-toast
Advanced tools
[![Version][version-badge]][package] [![MIT License][license-badge]][license]
A Toast component for react-native, supports Android, IOS, Web, Windows
Open a Terminal in the project root and run:
yarn add react-native-fast-toast
import React, { useEffect, useRef } from "react";
import Toast from "react-native-fast-toast";
export default function App() {
const toast = useRef(null);
useEffect(() => {
toast.current.show("Task finished successfully");
}, []);
return (
<>
<RestOfYourApp />
<Toast ref={toast} />
</>
);
If you want to have one Toast and use it everywhere on your app. do this in root component of your app (index.js or App.js)
import Toast from "react-native-fast-toast";
export default function App() {
return (
<>
<RestOfYourApp />
<Toast ref={(ref) => global['toast'] = ref} />
</>
);
now you can call toast.show()
everywhere on app. like alert.
TypeScript Note: add index.d.ts to your project root.
Alternatively you can use hooks to call toasts, to do so, wrap ToastProvier
to your root component (index.js or App.js)
import { ToastProvider } from 'react-native-fast-toast'
export default function App() {
return (
<ToastProvider>
<RestOfYourApp />
<ToastProvider/>
);
}
Then use hook like this everywhere:
import { useToast } from 'react-native-fast-toast'
const Component = () => {
const toast = useToast()
}
toast.show("Task finished successfully", { type: "success" });
toast.show("Task finished successfully", { icon: <Icon /> });
or
<Toast
ref={toast}
icon={<Icon />}
successIcon={<SuccessIcon />}
dangerIcon={<DangerIcon />}
warningIcon={<WarningIcon />}
/>
}
toast.show("Task finished successfully", {
duration: 5000,
style: { padding: 0 },
textStyle: { fontSize: 20 },
});
You can customize default options in Toast component
<Toast
duration={5000}
textStyle={{ fontSize: 20 }}
successColor="green"
dangerColor="red"
warningColor="orange"
normalColor="gray"
/>
<Toast
placement="bottom | top" // default to bottom
offset={50} // distance from bottom or top. ( default to 60 )
/>
If this project helped you reduce time to develop, you can buy me a cup of coffee :)
Pull request are welcome.
While developing, you can run the example app to test your changes.
MIT
FAQs
[![Version][version-badge]][package] [![MIT License][license-badge]][license]
The npm package react-native-fast-toast receives a total of 2,150 weekly downloads. As such, react-native-fast-toast popularity was classified as popular.
We found that react-native-fast-toast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.