You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-03 00:33:22 +03:00 
			
		
		
		
	Migrate away from Legacy React Contexts
This commit is contained in:
		@@ -26,8 +26,8 @@ import sanitizeHtml from 'sanitize-html';
 | 
			
		||||
import sdk from '../../index';
 | 
			
		||||
import dis from '../../dispatcher';
 | 
			
		||||
import MatrixClientPeg from '../../MatrixClientPeg';
 | 
			
		||||
import { MatrixClient } from 'matrix-js-sdk';
 | 
			
		||||
import classnames from 'classnames';
 | 
			
		||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
 | 
			
		||||
 | 
			
		||||
export default class EmbeddedPage extends React.PureComponent {
 | 
			
		||||
    static propTypes = {
 | 
			
		||||
@@ -39,9 +39,7 @@ export default class EmbeddedPage extends React.PureComponent {
 | 
			
		||||
        scrollbar: PropTypes.bool,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    static contextTypes = {
 | 
			
		||||
        matrixClient: PropTypes.instanceOf(MatrixClient),
 | 
			
		||||
    };
 | 
			
		||||
    static contextType = MatrixClientContext;
 | 
			
		||||
 | 
			
		||||
    constructor(props) {
 | 
			
		||||
        super(props);
 | 
			
		||||
@@ -104,7 +102,7 @@ export default class EmbeddedPage extends React.PureComponent {
 | 
			
		||||
 | 
			
		||||
    render() {
 | 
			
		||||
        // HACK: Workaround for the context's MatrixClient not updating.
 | 
			
		||||
        const client = this.context.matrixClient || MatrixClientPeg.get();
 | 
			
		||||
        const client = this.context || MatrixClientPeg.get();
 | 
			
		||||
        const isGuest = client ? client.isGuest() : true;
 | 
			
		||||
        const className = this.props.className;
 | 
			
		||||
        const classes = classnames({
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user