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 { useForm } from 'react-hook-form' | |
import { ErrorMessage } from '@hookform/error-message' | |
function App() { | |
// prettier-ignore | |
const { register, handleSubmit, formState: { errors } } = useForm() | |
const onSubmit = ({ username, password }) => { | |
alert(`Username: ${username}, Password: ${password}`) |
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 Character from './components/Character' | |
import { QueryClientProvider, QueryClient } from 'react-query' | |
const queryClient = new QueryClient() | |
function App() { | |
return ( | |
<div className="App"> | |
<QueryClientProvider client={queryClient}> |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"lib": ["dom", "dom.iterable", "esnext"], | |
"allowJs": true, | |
"skipLibCheck": true, | |
"esModuleInterop": true, | |
"allowSyntheticDefaultImports": true, | |
"strict": true, | |
"forceConsistentCasingInFileNames": true, |
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, { useState } from 'react' | |
import { | |
useGetPokemonByIdQuery, | |
useGetPokemonByNameQuery, | |
} from './services/pokemon' | |
function App() { | |
const [id, setId] = useState<number>(5) | |
const [name, setName] = useState<string>('bulbasaur') |
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 { Outlet } from 'react-router-dom' | |
export default function App() { | |
return <Outlet /> | |
} |
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
items.sort(function(a, b) { | |
return a.id - b.id || a.name.localeCompare(b.name); | |
}); |
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 { useState } = React; | |
function PageComponent() { | |
const [count, setCount] = useState(0); | |
const increment = () => { | |
setCount(count + 1) | |
} | |
return ( | |
<div className="App"> |
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 { NextResponse } from 'next/server' | |
import type { NextRequest } from 'next/server' | |
export function middleware(req: NextRequest) { | |
// get cookie token | |
const hasToken = req.cookies.get('token') | |
// protected routes (admin routes) | |
if (req.nextUrl.pathname.startsWith('/admin')) { | |
if (hasToken) { |
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 '../styles/globals.css' | |
import type { AppProps } from 'next/app' | |
import type { NextPage } from 'next' | |
import type { ReactElement, ReactNode } from 'react' | |
export type NextPageWithLayout = NextPage & { | |
getLayout?: (page: ReactElement) => ReactNode | |
} | |
type AppPropsWithLayout = AppProps & { |
OlderNewer