Closed lionchi closed 4 years ago
@mochixuan This is an example for a class component. And I need an example for a functional component. And from your class component, it's not clear where this.toastInstance is declared
function Test() {
const toastInstance = useRef(null);
function getToastInstance(instance){
toastInstance.current = instance;
}
return (
<Modal>
....
<ModalShowToastView toastInstance={this.getToastInstance}/>
</Modal>
)
}
More correct WModalShowToastView or ModalShowToastView? I have an error like this plan "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)" but got: undefined. You likely forgot to export your component from the file it's defined in, or you migth have mixed up default and named imports
Let me see, it’s my problem Fixed, the latest version 2.2.0
Updated but the error appears the same
It is runnable, I tested it on the latest package
I have the same error.
@mochixuan i copy ModalShowToastPage.js to my project and have the same error. annotation "ModalShowToastView toastInstance={this.getToastInstance} " is running, otherwise is error, like:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)" but got: undefined. You likely forgot to export your component from the file it's defined in, or you migth have mixed up default and named imports.
import { WModalShowToastView } from 'react-native-smart-tip'
Is it possible to use WModalShowToastView in functional components? If so, how to do this and preferably with an example.