I believe this can be solved using an arrow-function, but I'm not sure how. I would like to access this.props
inside of the render
Function. I know I could pass it over as an argument, but would rather not. Is this possible using arrow functions? If so, what do I need to change?
class View {
constructor(options) {
this.options = options;
}
render(el, props = {}) {
this.props = props;
el.innerHTML = this.options.render(el);
}
}
var Test = new View({
render() {
return `${this.props.test}`
//
// Also, tried ${props.test} in my template literal
//
}
});
Test.render(document.getElementById("main"), {
test:"123"
})