0.1.3 • Published 4 years ago

react_native_message_toast v0.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

react-native-message-toast

This is a highly customizable Toast message for React Native

npm version code style: prettier

Install

npm i react_native_message_toast

Demo

Usage

import MessageToast from 'react_native_message_toast';
const App = () => {
  const messageRef = useRef(null);

  return (
    <>
    {*...*}
      <MessageToast ref={messageRef} duration={2000} />

    // call show function from ref
      <Button
        title="Show Toast"
        onPress={() => messageRef.current.show('This is a toast message!')}
      />

      {*...*}
    </>
  );
};

export default App;

Custom design for toast message

const App = () => {
  const messageRef = useRef(null);

  const customDesign = () => {
    return (
      <View>
        {/* your custom design */}
      </View>
    );
  }

  return (
    <>
    {*...*}
      <MessageToast
        ref={messageRef}
        duration={2000}
        RenderMessage={(message) => customDesign(message)}
       />

    // call show function from ref
      <Button
        title="Show Toast"
        onPress={() => messageRef.current.show('This is a toast message!')}
      />

      {*...*}
    </>
  );
};

export default App;

Props

PropsTypeDescription
RenderMessagefunctionCustom design for toast message
durationnumberDuration for auto hide toast message
colorstringColor for message text

License

MIT