The below article will give you an overview with an example of how to use the useContext() hook and also update the globally set context value in c...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
For me, I had to add an empty
_value
like:Good working
It doesn't work for me, i don't have a getCopy, what this function does? could you please help me or get it touch with me!
Hey! Thank you for your message and sorry for the inconvenience caused.
Basically, getCopy() method could be anything whose result you want to set globally. In my case, it is a simple method which gets content based on the logged in user type.
For eg:
You can use localstorage for this:
Thank you for the alternative, however what if the user has disabled his localStorage? ;)
I did not know you can disable it
How will you change this when the objects to set and get are much more complex?
I have something like :
export interface IDocumentInfo {
file: IFilePickerResult;
pages?: number;
instructions?: string;
existsOnsite?: boolean;
}
export interface IRequestInfo {
projectNumber: string;
documents: IDocumentInfo[];
}
and I want a global context for an IRequestInfo object.
Thank you
Nice post
Thanks a lot Ben :). Being my first technical post, I am glad you liked it :)
medium.com/@masterrajpatel/useglob...
tried to explain the same , see if it can help others
Thanks a lot! I started lo learn Typescript recently and you save me a lot of time. I would buy you a beer if I could. Cheers!
haha, that is really sweet Manuel! Glad, I was able to help :)
Men o'zimga shuncha oldim.