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 { Box } from "@material-ui/core" | |
import { useTheme } from "@material-ui/styles" | |
function myComponent() { | |
const theme = useTheme() | |
return <Box padding={theme.spacing(4)} /> | |
} |
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 { Box, Theme } from "@material-ui/core" | |
import { useTheme } from "@material-ui/styles" | |
function myComponent() { | |
const theme = useTheme<Theme>() | |
return <Box padding={theme.spacing(4)} /> | |
} |
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 { Avatar, makeStyles } from "@material-ui/core" | |
const useAvatarStyles = makeStyles( | |
theme => { | |
colorDefault: { | |
// overriding `colorDefault` according to the Avatar API | |
backgroundColor: theme.palette.secondary | |
} | |
}, | |
{ name: "MuiAvatar" } |
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 { Avatar, makeStyles, Theme, createStyles } from "@material-ui/core" | |
const useAvatarStyles = makeStyles( | |
(theme: Theme) => | |
createStyles({ | |
colorDefault: { | |
// overriding `colorDefault` according to the Avatar API | |
backgroundColor: theme.palette.secondary | |
} | |
}), |
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 { makeStyles } from "@material-ui/core" | |
const useStyles = makeStyles(theme => ({ | |
myCustomClass: { | |
color: theme.palette.text.primary | |
} | |
})) | |
function myComponent() { | |
const classes = useStyles() |
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 { makeStyles, createStyles, Theme } from "@material-ui/core" | |
const useStyles = makeStyles((theme: Theme) => | |
createStyles({ | |
myCustomClass: { | |
color: theme.palette.text.primary | |
} | |
}) | |
) |
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
const hero = { | |
superman: { | |
name: "Superman", | |
alias: "Clark Kent" | |
}, | |
batman: { | |
name: "Batman", | |
alias: "Bruce Wayne" | |
}, | |
flash: { |
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
const sleep = (ms: number, dev: number = 1) => { | |
const msWithDev = (Math.random() * dev + 1) * ms | |
console.log('Sleeping', msWithDev / 1000, 'sec') | |
return new Promise(resolve => setTimeout(resolve, msWithDev)) | |
} | |
async function fetch() { | |
await sleep(1000) | |
} |
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, { Component } from "react" | |
import _ from 'lodash' | |
import hash from 'object-hash' | |
class Listings extends Component { | |
sortByIndex = (a, b, index, ascending) => (ascending ? a[index] - b[index] : b[index] - a[index]) | |
sortListings = _.memoize((listings, index, ascending) => | |
listings.sort((a,b) => this.sortByIndex(a, b, index, ascending)), | |
(...args) => `${hash(listings)}_${args[1]}_${args[2]}`) // Makes a hash in format: "objectHashId_beds_true" |
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, { Component } from "react"; | |
import _ from 'lodash' | |
class Listings extends Component { | |
sortByIndex = (a, b, index, ascending) => (ascending ? a[index] - b[index] : b[index] - a[index]) | |
sortListings = _.memoize((listings, index, ascending) => | |
listings.sort((a,b) => this.sortByIndex(a, b, index, ascending))) | |
render() { |