My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Passing non javascript object in Provider of useContext hook.

Nikhil Kumar's photo
Nikhil Kumar
·Jul 30, 2020·

1 min read

My react class is accepting an external object(COM window) as props, which is then passed to child elements. Instead of using prop drilling I am using useContext() hook to deliver prop where it is required.

<sampleContext.Provider value={nonJavascriptObj}>
<RootClass
....../>
</sampleContext.Provider>

So my question is can I pass a non javascript object mentioned above to provider. And expect to get the same object back with useContext()

I don't know much about the non javascript object, just that it is a C/C++ object and when I try to print it in console it looks something like this:

[Object] { }

It looks empty, but it isn't. This object is used to call a windows API.