Closed srmagura closed 1 year ago
Good point. So, you use some bundlers (vite?) that injects process.env.NODE_ENV
but not process
, right?
Yes, that is correct. I am using Webpack which replaces process.env.NODE_ENV
but does not actually define a process
object.
I have been thinking about this, also in another project, but the current way is fairly safe. I wish there were a standard way in the source code that works for CJS, ESM, browser and Deno. Until we know same good way, let's leave it.
For now, please configure your webpack to define process
as {}
in development mode.
Closing.
This code is intended to print a warning if you use
createContext
fromreact
rather thanuse-context-selector
. I made this mistake and the warning was not printed. This happens becausetypeof process
is expected to be'undefined'
when running in the browser. Going to submit a PR for this.https://github.com/dai-shi/use-context-selector/blob/06a2c827bb19654c44952f098ba8e1fc4807e645/src/index.ts#L159-L163