Reputation: 14856
import Foo from 'file'
if (inDevelopment) {
Foo = null
}
I would like to do this, but it results in
SyntaxError: "Foo" is read-only
Is there anything that changes the default const behavior, like let import Foo from 'file'
? 😊
Upvotes: 0
Views: 1608
Reputation: 664503
You don't. Use a second variable:
import Foo from 'file'
const LocalFoo = inDevelopment ? null : Foo;
Only the module that exported the variable can change its value, although non-constant exports are weird to work with.
Upvotes: 3