Skip to content

Instantly share code, notes, and snippets.

@GarySwift
Created May 12, 2022 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GarySwift/3326608dda01355650b26bae0b145db2 to your computer and use it in GitHub Desktop.
Save GarySwift/3326608dda01355650b26bae0b145db2 to your computer and use it in GitHub Desktop.
Simple Reusable Components in ES6
import { helloWorld } from './lib/hello-world';
import sayHello from './lib/say-hello';
$(document).ready(function() {
sayHello(helloWorld);
// Hello Friend
});
const helloWorld = {
hello: function(name) {
return 'Hello ' + name;
}
}
export { helloWorld }
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