You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
After Babel 7.9.x Update exactly @babel/preset-env -> @babel/plugin-transform-classes
We have issue with proper context in Container components. Constructor has different context than render function.
Until the update similar code to this one had been working properly (v7.8.6), we could bind functions in constructor and pass them to children components as props.
Example reproduction:
import React from 'react';
import FluxUtils from 'flux/utils';
import { Dispatcher } from 'flux';
class Store extends FluxUtils.ReduceStore {
constructor() { super(new Dispatcher()); }
getInitialState() { return {}; }
reduce(state) { return state; }
}
const store = new Store();
let self;
class Component extends React.Component {
static getStores() { return [store] }
static calculateState() { }
constructor() {
super();
this.foo = this.foo.bind(this);
self = this;
}
foo() {
console.log(this === self);
}
render() {
console.log(this === self); // false
this.foo() // false
const obj = Object.assign({}, {foo: this.foo })
obj.foo(); // foo is not binded so will be called with obj context so print false
return (
<p> hello</p>
);
}
}
export default FluxUtils.Container.create(Component);
Thanks for the report! I've switched teams and haven't worked on Flux in quite a while, if anyone is able to help debug this and submit a PR that would be great. I will be able to merge it and do a release. If not this may be a bit slower to get resolved.
Had the same error, seems to be caused by the older Babel version used to generate the dist files for this repo. I updated my build to have current Babel transpile the source files and my app works again.
@pmysinski@rvignacio
I've updated Babel to the latest version and published it as @koba04/flux temporally. #495
It would be helpful for me if you would test the pacakge whther it works fine or not.
After Babel 7.9.x Update exactly @babel/preset-env -> @babel/plugin-transform-classes
We have issue with proper context in Container components.
Constructor has different context than render function.
Until the update similar code to this one had been working properly (v7.8.6), we could bind functions in constructor and pass them to children components as props.
Example reproduction:
Babel:
package.json
I'm not sure whos issue this is babel or flux but it would nice to have this back to work how it used to:)
The text was updated successfully, but these errors were encountered: