I hereby claim:
- I am theham3d on github.
- I am theham3d (https://keybase.io/theham3d) on keybase.
- I have a public key whose fingerprint is 410B 6B14 F87C B767 CE31 3B2B 2A4C 27B1 D95B C268
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import React , { Component } from 'react'; | |
class CatchError extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { hasError: false }; | |
} | |
static getDerivedStateFromError(error) { | |
// if something happens this will update state so the next render will show our fallback UI. | |
return { hasError: true }; |
import React , { useReducer } from 'react'; | |
const initialState = {count: 0}; | |
const yourReducer = (state, action) => { | |
switch (action.type) { | |
case 'reset': | |
return initialState; | |
case 'increment': | |
return {count: state.count + 1}; | |
case 'decrement': |
import React , { useContext } from 'react'; | |
import { AppContext } from './App'; | |
const MyComponent = props => { | |
const value = useContext(AppContext); | |
return <h1>{value}</h1>; | |
} | |
export default MyComponent; |
import React, { Component } from 'react'; | |
class ClassComponent extends Component { | |
componentDidMount() { | |
fetchSomething(); | |
} | |
render() { | |
return <div>شیب، بام؟</div>; | |
} |
import React , { useState } from 'react'; | |
const MyCounter = props => { | |
const [count, setCount] = useState(0); | |
//you can use useState as much as you want | |
return ( | |
<div> | |
<h1>{count}</h1> | |
<button onClick={() => setCount(count + 1)}>Click me</button> |
import React , { Component } from 'react'; | |
import { AppContext } from './App'; | |
class MyComponent extends Component { | |
componentDidMount() { | |
let value = this.context; | |
/* و قص علی هذا */ | |
} | |
componentDidUpdate() { | |
let value = this.context; |
import React , { lazy , Suspense } from 'react'; | |
const ShomalComponent = lazy(() => import('./ShomalComponent')); | |
const MyComponent = props => ( | |
<Suspense fallback={<div>Loading...</div>}> | |
<ShomalComponent /> | |
</Suspense> | |
); | |
export default MyComponent; |
import React , { memo } from 'react'; | |
const ShomalComponent = props => ( | |
<div> | |
<p>?چرا در شمال ایران سقف اکثر خانه ها را شیب دار میسازند</p> | |
</div> | |
); | |
export default memo(ShomalComponent) |