Skip to content
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

toast.show("Hello World"); is undefines or not a function in multiple times #186

Open
H-57 opened this issue Feb 7, 2024 · 7 comments
Open
Labels
bug Something isn't working

Comments

@H-57
Copy link

H-57 commented Feb 7, 2024

Current behaviour

At first build all works fine but after modified any code it reload app ant toast show undefined

Expected behaviour

return undefined not show mesage

Code sample

For Syntax Highlighting check this link
`const Main = () => {
const [Screen, setScreen] = useState('logo')
const toast = useToast();

useEffect(() => {
toast.show("Hello World");
}, []);

`

Screenshots (if applicable)

Capture

What have you tried

Your Environment

software version
ios or android android 10
react-native "0.73.1"
react-native-toast-notifications "^3.4.0",
node 20.11
npm or yarn
@H-57 H-57 added the bug Something isn't working label Feb 7, 2024
@Dun-sin
Copy link

Dun-sin commented Feb 23, 2024

same bug here

@muhamadjawad
Copy link

same here

@PopBot
Copy link

PopBot commented Mar 5, 2024

I am getting this on web too.

@PopBot
Copy link

PopBot commented Mar 7, 2024

Fixed! I realized the ToastProvider wasn't mounting in time, causing the reference to toast to be undefined. Just make sure your parent context state fully mounts before rendering the child with toast in it.

@sofi-algoritcom
Copy link

same here

@mahmingtea
Copy link

const toast = useToast();
const isToastLoaded = () => {
    return Object.entries(toast).length === 0;
  };
useEffect(() => {
    if (!isToastLoaded()) {
      toast.show("Loading...")
     }
},[isToastLoaded()])

Like this

@yasiraktunc
Copy link

Fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants