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

Using useEffect in config - Warning: Internal React error: Expected static flag was missing. Please notify the React team. #540

Open
cs-manughian opened this issue Apr 19, 2024 · 0 comments

Comments

@cs-manughian
Copy link

cs-manughian commented Apr 19, 2024

Describe the bug
The following error appears when using the custom toast functionality in the React Native Web emulator with a useEffect hook:

console.js:273 Warning: Internal React error: Expected static flag was missing. Please notify the React team.
    at ToastUI (http://localhost:19006/static/js/bundle.js:17604:25)
    at http://localhost:19006/static/js/bundle.js:17456:22
    at LoggerProvider (http://localhost:19006/static/js/bundle.js:18089:23)
    at Toast (http://localhost:19006/static/js/bundle.js:17493:63)

I suspect this is caused by my desire to use a useEffect hook in the custom toast function:

const toastConfig = {
  customToast: ({ text1, props }: ToastConfigParams<any>) => {
    // Call external function that generates encouraging sayings; Update the saying when the text changes
    const [encouragement, setEncouragement] = useState<string>();
    useEffect(() => {
      const saying = getNextSaying();
      setEncouragement(saying);
    }, [text1]);

    return (
      <View style={styles.base}>
        ...
      </View>
    )
  }
}

Steps to reproduce
Steps to reproduce the behavior:

  1. Make a custom toast config
  2. Add a useEffect hook that sets local state based on text1 changes
  3. See error when toast appears

Expected behavior
I don't expect this error to appear. The toast seems to be working in the web emulator. I have not tested on a device yet.

Screenshots
Console error in Chrome, run with the expo web emulator:
image

Environment:

  • OS: [Web Emulator]
  • react-native-toast-message version: [^v2.0.0]
  • react-native version [v0.72.10]

Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant