Created
May 12, 2022 21:09
-
-
Save GarySwift/3326608dda01355650b26bae0b145db2 to your computer and use it in GitHub Desktop.
Simple Reusable Components in ES6
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 { helloWorld } from './lib/hello-world'; | |
import sayHello from './lib/say-hello'; | |
$(document).ready(function() { | |
sayHello(helloWorld); | |
// Hello Friend | |
}); |
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
const helloWorld = { | |
hello: function(name) { | |
return 'Hello ' + name; | |
} | |
} | |
export { helloWorld } |
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
export default function(helloWorld) { | |
console.log(helloWorld.hello('Friend')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment