How to use React's context API outside of react's component scope : ReactJS
问题 I am using react's context API for storing USER_TOKEN for authentication purposes. Also I am maintaining a common fetch function in a separate module where I want to use this USER_TOKEN. And Its obvious that I cannot use this USER_TOKEN inside this module as it is not a react component. Is there any way I can use this USER_TOKEN inside this fetch function. I am storing USER_TOKEN into a context API variable after successful sign-in. Yes I know we could pass the variable from context whenever