-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript-class component toast message in modal usage #172
Comments
Hi @tarikpnr , try creating a ref in the class constructor using React.createRef constructor(props) {
super(props);
this.modalRef = React.createRef();
} |
Im guessing in order to access the functions of Toast I need to specify a type to it. Currently if I try to use toast message on modal The way I use the show function is shown below; |
@tarikpnr to hide it, you need to call this.modalRef.current.show({
...
onPress: () => this.modalRef.current.hide()
}) As for creating the ref, you can set it to be of this.modalRef = React.createRef<Toast>(); |
1+, I am with the same problem |
To fix the typescript error, i just created a variable and in the ref, added // doing this for autocompletion, could be set to null
let modalToastRef = Toast
// then set the variable to the ref
<Toast ref={ref => (modalToastRef = ref)} /> |
Fixed in If you find any issues with the v2 implementation, feel free to reopen this issue. Thanks! |
Hello. I wanted to use toast message in a modal. I initialized the steps related to showing in modal as shown in docs. But having problem while creatingRef. What should be the proper way to use toast message in typescript- class component ?
The error is shown in screenshot above. Any help would be great. Thanks...
The text was updated successfully, but these errors were encountered: