#Context API doesn't seem to work for me -Nextjs13

4 messages · Page 1 of 1 (latest)

topaz arch
#

Hi I am tryin to get the Context API to work in my Next13 app, but I keep getting *undefined *as value returned from the context. Any function call (e.g. a fetch request ) that is called in a page/component gives the <function_name> is not a function error. I am trying not to go into the rabbit hole of redux as my app is small

stiff crestBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

torn plover
#

cool story but unless you show the code, nobody will know the context

topaz arch
#
import { useContext, createContext, useState } from "react";

export const AuthContext = createContext()


function AuthProvider({children}){
    const [test,setTest] = useState('test material')
    
   const test2 = 'kiln'



    return (
        <AuthContext.Provider value={{test, test2}}>
            {children}
        </AuthContext.Provider>
    )
}

export default AuthProvider```
@torn plover  the context