This file contains hidden or 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
export const useOnForegroundFocus = ( | |
onFocus: () => void, | |
runOnStartup: boolean | undefined = false | |
) => { | |
const appState = useRef(AppState.currentState); | |
useEffect(() => { | |
const subscription = AppState.addEventListener('change', (nextAppState) => { | |
if ( | |
appState.current.match(/inactive|background/) && |
This file contains hidden or 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
app.post( | |
"/bulk-edit", | |
celebrate({ | |
body: Joi.object({ | |
title: Joi.string().required().min(8).max(240), | |
description: Joi.string().required().min(8) | |
}), | |
query: Joi.object({ | |
type: Joi.string() | |
}) |
This file contains hidden or 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
app.post( | |
"/signin", | |
celebrate({ | |
body: Joi.object({ | |
email: Joi.string().required().email(), | |
password: Joi.string().required().min(8) | |
}) | |
}), | |
(req, res) => { | |
// ... |
This file contains hidden or 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'; | |
const Layout : React.FC = () => { | |
const { mode, setMode } = useTheme(); | |
return <div style={{ background: mode === "light" ? "#fff" : "#000", color: mode === "light" ? "#000" : "#fff" }} > | |
<h1>Welcome!</h1> | |
<button onClick={() => setMode(mode === "light" ? "dark" : "light")}> | |
toggle theme | |
</button> |
This file contains hidden or 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 { ThemeProvider } from './theme-provider'; | |
import Layout from './layout'; | |
const App : React.FC = () => { | |
return <ThemeProvider> | |
<Layout />; | |
</ThemeProvider>; | |
} |
This file contains hidden or 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, { createContext, useContext, useState, PropsWithChildren } from "React"; | |
type modeType = "light" | "dark"; | |
interface ThemeState { | |
mode: modeType; | |
setMode(mode: modeType): void; | |
} | |
const defaultThemeState : ThemeState = { |
This file contains hidden or 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
export const usePerson = () => { | |
const [firstName, setFirstName] = useState(""); | |
const [lastName, setLastName] = useState(""); | |
const fullName = `${firstName} ${lastName}` | |
return { fullName, setFirstName, setLastName } | |
} |
This file contains hidden or 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 { StyleSheet, Text, View, Button, Alert } from "react-native"; | |
import { AuthSession } from "expo"; | |
import jwtDecode from "jwt-decode"; | |
const auth0_client_id = "[YOUR_AUTH0_CLIENT_ID]"; | |
const auth0_domain = "[YOUR_AUTH0_DOMAIN]"; | |
const toQueryString = params => { |
This file contains hidden or 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 { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd"; | |
function App() { | |
const [data, updateData] = useState({ | |
backlog: [1, 3, 5, 6, 7, 8, 9], | |
todo: [2, 4], | |
doing: [10, 11, 12], | |
done: [] | |
}); |
This file contains hidden or 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 { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd"; | |
function App() { | |
const [items, updateItems] = useState([1, 2, 3, 4, 5]); | |
const [selected, updateSelected] = useState([6, 7, 8]); | |
const reorder = (list, startIndex, endIndex) => { | |
const result = Array.from(list); | |
const [removed] = result.splice(startIndex, 1); |
NewerOlder