Skip to content

Clean up hooks #384

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

Closed
hendaoui opened this issue Jun 12, 2020 · 2 comments
Closed

Clean up hooks #384

hendaoui opened this issue Jun 12, 2020 · 2 comments

Comments

@hendaoui
Copy link

hendaoui commented Jun 12, 2020

Current behavior

React Native warning: An effect function must not return anything besides a function, which is used for clean -up...
AsyncStorage is working, but this warning is always fired on

Expected behavior

No warnings

Repro steps

  const [step, setStep] = useState(1);
  useEffect(() => {
    checkStep();
  }, []);

  const checkStep = async () => {
    try {
      await AsyncStorage.getItem('onBoardingDone').then(item => {
        if (item !== null) {
          setStep(3);
        }
      });
    } catch (error) {}
  };

  const finsishOnBoarding = () => {
    try {
      AsyncStorage.setItem('onBoardingDone', 'true').then(() => {
        setStep(2);
      });
    } catch (error) {}
  };

Environment

  • Async Storage version: ^1.11.0
  • React-Native version: 0.62.2
  • Platform tested: Android
@nishit130
Copy link

@hendaoui check this answer on stack overflow hope it solves your problem

@krizzu
Copy link
Member

krizzu commented Jun 17, 2020

I don't recommend to use Hook API for Async Storage for now - it needs to be revisited.

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

3 participants