From 632291d4812326410619bca2742ad325f0fd8d8f Mon Sep 17 00:00:00 2001
From: Rohit Mehta <63762981+r0hitm@users.noreply.github.com>
Date: Thu, 2 Nov 2023 23:28:49 +0530
Subject: [PATCH 1/2] Added updated code for src/App.jsx that uses the
IdeasContext
---
.../docs/tutorials/react/step-6/+page.markdoc | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/routes/docs/tutorials/react/step-6/+page.markdoc b/src/routes/docs/tutorials/react/step-6/+page.markdoc
index e90a9ed455..f13531e2ae 100644
--- a/src/routes/docs/tutorials/react/step-6/+page.markdoc
+++ b/src/routes/docs/tutorials/react/step-6/+page.markdoc
@@ -80,3 +80,52 @@ export function IdeasProvider(props) {
}
```
+# Using `IdeasContext`
+
+Update `src/App.jsx` to use the `IdeasProvider`:
+
+```js
+import { Login } from "./pages/Login";
+import { Home } from "./pages/Home";
+import { UserProvider, useUser } from "./lib/context/user";
+import { IdeasProvider } from "./lib/context/ideas";
+
+function App() {
+ const isLoginPage = window.location.pathname === "/login";
+
+ return (
+
+
+ {/* Add the navbar before page content */}
+
+ {isLoginPage ? : }
+
+
+
+ );
+}
+
+function Navbar() {
+ const user = useUser();
+
+ return (
+
+ );
+}
+
+export default App;
+```
From 2e72fa30ee42419b96afce2e3f56bd4f3ea122c4 Mon Sep 17 00:00:00 2001
From: Rohit Mehta <63762981+r0hitm@users.noreply.github.com>
Date: Thu, 2 Nov 2023 23:33:57 +0530
Subject: [PATCH 2/2] correct account.create syntax
---
src/routes/docs/tutorials/react/step-4/+page.markdoc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/routes/docs/tutorials/react/step-4/+page.markdoc b/src/routes/docs/tutorials/react/step-4/+page.markdoc
index a9ed0fb0c1..1c90c42e47 100644
--- a/src/routes/docs/tutorials/react/step-4/+page.markdoc
+++ b/src/routes/docs/tutorials/react/step-4/+page.markdoc
@@ -15,6 +15,7 @@ Create a new file `src/lib/context/user.jsx` and add the following code to it.
```js
import { createContext, useContext, useEffect, useState } from "react";
import { account } from "../appwrite";
+import { ID } from "appwrite";
const UserContext = createContext();
@@ -36,7 +37,7 @@ export function UserProvider(props) {
}
async function register(email, password) {
- await account.create(email, password);
+ await account.create(ID.unique(), email, password);
await login(email, password);
}