Created
June 10, 2020 06:02
-
-
Save martsie/7a284721fc278724886bb6685919d36c to your computer and use it in GitHub Desktop.
Lewagon #404 Component template
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 MyComponent from "./components/MyComponent"; | |
const initPlugin = (querySelector, Component) => { | |
const els = document.querySelectorAll(querySelector); | |
if (els) { | |
els.forEach(el => { | |
Component(el); | |
}); | |
} | |
}; | |
initPlugin(".js-my-component", MyComponent); |
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 MyComponent = (rootElement) => { | |
const subEl = rootElement.querySelector('.js-some-btn'); | |
console.log(rootElement, "i'm working!"); | |
}; | |
export default MyComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment