This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import useAppReducer from 'Hooks/useAppReducer' | |
export default function Foo () { | |
const [state, dispatch] = useAppReducer() | |
// can read state or dispatch action to appReducer | |
return ( | |
... | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserRouter } from 'react-router-dom' | |
import Routes from 'Routes' | |
import { useAppReducer, AppReducerContext } from 'Hooks/useAppReducer' | |
export default function App () { | |
const appReducer = useAppReducer() | |
return ( | |
<AppReducerContext.Provider value={appReducer}> | |
<BrowserRouter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useMemo, createContext, useContext } from 'react' | |
import useMedia from 'Hooks/useMedia' | |
export const BreakpointsContext = createContext() | |
// for provider | |
export function useBreakpoints ({ | |
sm = 480, | |
md = 960, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SignIn (props) { | |
const [username, setUsername] = useState('') | |
const [password, setPassword] = useState('') | |
const [pending, setPending] = useState('') | |
const [error, setError] = useState({}) | |
useEffect(()=>{ | |
if(pending) { | |
api.signIn(username, password) | |
.then(res => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MyComponent = () => ( | |
<Suspense fallback={<div>Loading...</div>}> | |
<AsyncComponent /> | |
</Suspense> | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Switch, Route } from 'react-router-dom' | |
import Loadable from 'react-loadable' | |
const Loading = () => <div>loading...</div> | |
const Home = Loadable({ | |
loader: () => import('./Home'), | |
loading: Loading | |
}) |
OlderNewer