Skip to content

Commit

Permalink
Fix RN tutorial code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
cbush authored and nlarew committed Oct 16, 2020
1 parent 1106b57 commit 4832c61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
9 changes: 6 additions & 3 deletions source/includes/steps-tutorial-react-native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ content: |
cd ..
Once the dependency installations are complete, you can run the app using one
of the following commands, depending on whether you want to run on Android or
iOS:
of the following commands, depending on whether you want to run on iOS:
.. code-block:: shell
npx react-native run-ios
# OR
Or Android (note: you may need to install Android development tools):
.. code-block:: shell
npx react-native run-android
---
title: Explore the App Structure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
return () => {
// cleanup function
const userRealm = realmRef.current;
if (userRealm) {
userRealm.close();
realmRef.current = null;
setProjectData([]); // set project data to an empty array (this prevents the array from staying in state on logout)
}
};
}, [user]);

// :code-block-start: sign-in
// The signIn function takes an email and password and uses the
// emailPassword authentication provider to log in.
const signIn = async (email, password) => {
const creds = Realm.Credentials.emailPassword(email, password);
const newUser = await app.logIn(creds);
setUser(newUser);
return () => {
// cleanup function
const userRealm = realmRef.current;
if (userRealm) {
userRealm.close();
realmRef.current = null;
setProjectData([]); // set project data to an empty array (this prevents the array from staying in state on logout)
}
};
1 change: 1 addition & 0 deletions tutorial/rn/providers/AuthProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const AuthProvider = ({ children }) => {
// :replace-with:
//// TODO: Return a cleanup function that closes the user realm.
// :hide-end:
// :code-block-end:
}, [user]);

// :code-block-start: sign-in
Expand Down

0 comments on commit 4832c61

Please sign in to comment.