Closed Urkass closed 6 years ago
@Urkass Could you provide a minimal example reproducing error? because I couldn't (
@dfilatov reproducing example:
class Hello extends vidom.Component {
constructor(a) {
super(a);
this.setState({ counter : 1 });
}
onRender() {
return (
<div>
<h1>Hello, { this.attrs.name }!</h1>
<div>I see you { this.state.counter } time</div>
</div>
);
}
onMount() {
setInterval(() => {
this.setState({ counter : this.state.counter + 1 });
}, 1000);
}
}
vidom.mount(document.body, <Hello name="World"/>);
After attent look at docs I found that for this purposes i should use onInit
that removes the need in constructor
and super
.
One more question, what ie browsers does vidom support?
Constructor has following signature: constructor(attrs, children, context)
. You was trying to pass attrs
only so base constructor had been broken. And yes, much better to avoid constructor overriding and use onInit
hook.
what ie browsers does vidom support?
>= IE9
https://github.com/dfilatov/vidom/blob/2355f72c8da810dfa57f2d88406fb58b406eb5f1/src/createComponent.js#L199 while using
super()
in constructor of a component,Object.freeze(rootNodeCtx)
receivesundefined
. It causes an Error in ie11Object.freeze: argument is not an Object