Giter VIP home page Giter VIP logo

Comments (9)

caleb-harrelson avatar caleb-harrelson commented on May 23, 2024

The typescript declarations were manually created via a pull request (the library is not written in typescript). The errors you are getting are because the declarations have not been updated for the new version’s features.

from react-native-toast-message.

dpnick avatar dpnick commented on May 23, 2024

Oh ok i understand, could you tell me if this is in your backlog ?
Thanks for your help and for your quick answer!

from react-native-toast-message.

calintamas avatar calintamas commented on May 23, 2024

Hi @dpnick, updated type declaration in v1.4.1. Please let me know if it works

from react-native-toast-message.

dpnick avatar dpnick commented on May 23, 2024

Hi @calintamas, i can now have access to config prop and BaseToast but i have another issue trying to custom with BaseToast :
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

I looked at your index.d.ts and i think this problem comme from the export of BaseToast, you did it like :
export const BaseToast: React.FC<BaseToastProps>
But i think it sould be a function (just like this related issue facebook/react#13445)

Thanks for your quick fix πŸ‘

from react-native-toast-message.

caleb-harrelson avatar caleb-harrelson commented on May 23, 2024

React.FC<BaseToastProps>

That's a typescript shortcut for "functional component that accepts props of type BaseToastProps", so the exported type is already a function, not an element as was the problem in the linked issue.

from react-native-toast-message.

dpnick avatar dpnick commented on May 23, 2024

Ok thanks, any ideas ?
@calintamas if you need my code to reproduce let me know!

from react-native-toast-message.

calintamas avatar calintamas commented on May 23, 2024

@dpnick yes, that would help

from react-native-toast-message.

dpnick avatar dpnick commented on May 23, 2024

Actually it was pretty simple (based on your example from the documentation) :

 import Toast, { BaseToast, BaseToastProps } from 'react-native-toast-message';

  const toastConfig = {
    success: ({ text1, text2, ...rest }: BaseToastProps) => (
      <BaseToast
        {...rest}
        style={{ borderLeftColor: 'pink' }}
        text1={text1}
        text2={text2}
      />
    )
  };

 export default function App() {
      return (
         {...}
            <Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} />
         {...}
     );
 }

from react-native-toast-message.

calintamas avatar calintamas commented on May 23, 2024

@dpnick try setting the config arg type to any, since it does not exactly represent BaseToastProps - it has extra keys like position, type, hide, show etc

const toastConfig = {
    success: ({ text1, text2, ...rest }: any) => ()
  };

If you have a suggestion on how to do this better, let me know

from react-native-toast-message.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.