I can see the error but need to see the source code of this page and perhaps the context as well. React hooks follow camel case React.useContext(ImageContext).
The name of the image is up to you and how u want to use it. If u want to hardcode it "image" that’s ok, but you might want to set it dynamically as well so I’d recommend assigning value from context.
It’s impossible to see what the issue is though, as you’re not providing enough code to see where the issue is – we can’t see if you’re using some library, or if you’ve written code for the context somewhere else, or whatever. I think there are more errors w/r/t to what you’re writing, but need more info
valuehas to be an object, whereas this is (I assume) a string. value is literally the context, it’s the thing you access. Like you’re trying to access context.path but that property doesn’t exist, you haven’t defined it.
valuehas to be an object, whereas this is (I assume) a string. value is literally the context, it’s the thing you access. Like you’re trying to access context.path but that property doesn’t exist, you haven’t defined it.
I recommend using a linter like ESLint or TSLint to solve all the syntactical errors. Might want to even add Typescript for React to solve the typing errors, they will show up when you’re not passing the right stuff.
Yes, the context provider takes a single prop, value. That is always an object: the point of a context is that you can access that object anywhere further down the tree.
If that value is a string, then the provider code is wrong. In the consumer you are trying to access context.somePropertyOfTheValueObject and because value isn’t an object, there is nothing to access, it won’t work. You have to write like Provider value={{ property: "an object property" }}>, the thing that has to go here: value={HERE} has to be object, that’s the value of the context
There seem to be other basic syntactic errors here, which is why you’re being advised to lint the code, ie install a plugin in your IDE that highlights errors
If you are just adjusting a template here and you don’t really understand what it is you’re doing, the code is complex and so I would write a few small examples first, following the React docs, so that you understand what you’re doing.