From cfeea423d3638d4b48f45dde3545297dd2014fcf Mon Sep 17 00:00:00 2001 From: Adam La Morre Date: Sun, 17 Oct 2021 13:19:14 -0400 Subject: [PATCH 1/3] context --- index.js | 17 +++++++++++++++++ pages/_app.js | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..1bc1a56 --- /dev/null +++ b/index.js @@ -0,0 +1,17 @@ +import React, { useState, createContext } from "react"; + +export const Context = createContext(); + +export const ContextProvider = () => { + const [username, setUsername] = useState(""); + const [secret, setSecret] = useState(""); + + const value = { + username, + setUsername, + secret, + setSecret, + }; + + return {props.children}; +}; diff --git a/pages/_app.js b/pages/_app.js index ccb4308..5b2a830 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -2,12 +2,12 @@ import "../styles/auth.css"; import "../styles/chats.css"; import "../styles/index.css"; -// import { ContextProvider } from '../context' +import { ContextProvider } from "../context"; export default function App({ Component, pageProps }) { return ( - // - - // + + + ); } From d0fb78726dc100d29bcf622e4f4a93a038322ad2 Mon Sep 17 00:00:00 2001 From: Adam La Morre Date: Sun, 17 Oct 2021 13:23:36 -0400 Subject: [PATCH 2/3] proper context location --- index.js => context/index.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename index.js => context/index.js (100%) diff --git a/index.js b/context/index.js similarity index 100% rename from index.js rename to context/index.js From 9e957c0ee2b15d714bc5ad3e4d139a625c59d38f Mon Sep 17 00:00:00 2001 From: Adam La Morre Date: Fri, 22 Oct 2021 07:53:04 -0400 Subject: [PATCH 3/3] Missing props --- context/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context/index.js b/context/index.js index 1bc1a56..e28a9e5 100644 --- a/context/index.js +++ b/context/index.js @@ -2,7 +2,7 @@ import React, { useState, createContext } from "react"; export const Context = createContext(); -export const ContextProvider = () => { +export const ContextProvider = (props) => { const [username, setUsername] = useState(""); const [secret, setSecret] = useState("");