Last active
July 2, 2017 03:03
-
-
Save aaccurso/38b9c3a6a5f62e74e221c04e752bf69f to your computer and use it in GitHub Desktop.
Allow importing modules from the `src/` directory example.
This file contains 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
// Location: src/components/deep/module/foo/Foo.js | |
import React, { Component} from 'react'; | |
// We want to avoid importing modules relative to the current file | |
// import Bar from '../../../../bar/Bar.js'; | |
// Instead we want to have a clearer way of importing modules relative to `src/` | |
import Bar from 'components/bar/Bar.js'; | |
export default class Foo extends Component { | |
render() { | |
return ( | |
<div> | |
Foo <Bar/> | |
</div> | |
); | |
} | |
} |
This file contains 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
// Location: src/components/bar/Bar.js | |
import React, { Component} from 'react'; | |
export default class Bar extends Component { | |
render() { | |
return <span>Bar</span>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment