Created
November 3, 2017 08:55
-
-
Save carmichaelize/6040b0fa0809a82d50d4e3a125bcbfe3 to your computer and use it in GitHub Desktop.
React — Importing Global Variables from the Window Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Foo from './foo-service'; | |
class FooComponent extends Component { | |
foo = Foo; | |
render() { | |
return (<div>{this.foo.name}</div>) | |
} | |
} | |
export default FooComponent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare var Foo; | |
export default window.Foo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment