testshallpass / react-native-dropdownalert

An alert to notify users about an error or something else
MIT License
1.85k stars 252 forks source link

Issues with .tsx files and ref #242

Closed GaboFlo closed 3 years ago

GaboFlo commented 3 years ago

Short Description

Inspired by the example in your repo, I'm trying tu use DropDownAlert in a .tsx file simplified as follow:

import DropdownAlert from 'react-native-dropdownalert'
...

export const MyFunction=()=>{
let dropDownAlertRef = useRef(null)
...

const mySubFunction = ()=> { 
dropDownAlertRef.alertWithType('success', 'You did it !' (1)
...
}

<View>
      <DropdownAlert
        ref={(ref) => {
          if (ref) {
            dropDownAlertRef = ref (2)
          }
        }}
      />
</View>
}

...

Steps to Reproduce / Code Snippets / Usage

Typescript says Property 'alertWithType' does not exist on type 'MutableRefObject<any>' (1) Property 'current' is missing in type 'DropdownAlert' but required in type 'MutableRefObject<any> (2)

Expected Results

Well the DropDownAlert doesn't show, I'd like it will ;) Do you know what is wrong and how to fixe it ?