Migrate away from Legacy React Contexts
This commit is contained in:
parent
2e8d66fa36
commit
937b32663c
55 changed files with 651 additions and 750 deletions
|
@ -9,6 +9,7 @@ import jssdk from 'matrix-js-sdk';
|
|||
import {makeType} from "../src/utils/TypeUtils";
|
||||
import {ValidatedServerConfig} from "../src/utils/AutoDiscoveryUtils";
|
||||
import ShallowRenderer from 'react-test-renderer/shallow';
|
||||
import MatrixClientContext from "../src/contexts/MatrixClientContext";
|
||||
const MatrixEvent = jssdk.MatrixEvent;
|
||||
|
||||
/**
|
||||
|
@ -291,22 +292,16 @@ export function getDispatchForStore(store) {
|
|||
|
||||
export function wrapInMatrixClientContext(WrappedComponent) {
|
||||
class Wrapper extends React.Component {
|
||||
static childContextTypes = {
|
||||
matrixClient: PropTypes.object,
|
||||
}
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
getChildContext() {
|
||||
return {
|
||||
matrixClient: this._matrixClient,
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this._matrixClient = peg.get();
|
||||
}
|
||||
|
||||
render() {
|
||||
return <WrappedComponent ref={this.props.wrappedRef} {...this.props} />;
|
||||
return <MatrixClientContext.Provider value={this._matrixClient}>
|
||||
<WrappedComponent ref={this.props.wrappedRef} {...this.props} />
|
||||
</MatrixClientContext.Provider>;
|
||||
}
|
||||
}
|
||||
return Wrapper;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue