Skip to content

Instantly share code, notes, and snippets.

@theham3d
Created October 31, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theham3d/594542a90061eea05382a8fef6eaaa49 to your computer and use it in GitHub Desktop.
Save theham3d/594542a90061eea05382a8fef6eaaa49 to your computer and use it in GitHub Desktop.
rcContextType
import React , { Component } from 'react';
import { AppContext } from './App';
class MyComponent extends Component {
componentDidMount() {
let value = this.context;
/* و قص علی هذا */
}
componentDidUpdate() {
let value = this.context;
/* و قص علی هذا */
}
componentWillUnmount() {
let value = this.context;
/* و قص علی هذا */
}
render() {
let value = this.context;
return <h1>{value}</h1>;
}
}
MyComponent.contextType = AppContext;
export default MyComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment