You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-13 23:41:50 +03:00
Migrate away from Legacy React Contexts
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user