I have javascript application building on modules. I am using webpack. I want to add eventlistener to element. But i can't do it. I receive the error "ReferenceError: x is not defined". Where in my app i should place my eventlistener function. It works if i write function inline, but i don't want to do that.
Here is my app.js file (entry point).
import {Main} from "./components/Main";
import './style.css'
export default (function () {
document.getElementById("app").innerHTML = Main();
}());
Component with element i want to have eventlistener - onclick in element:
import {CompanyContainer} from "./CompanyContainer";
export const UserContainer = user => {
return (
`
<a href="#" onclick="">${user.getFullName()}</a>
<div class="user-details hide">
<p>Birthday: ${user.getBirthDay()}</p>
<p><img src="" width="100px"></p>
${CompanyContainer(user.companyId)}
</div>
`
)
};