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
| // https://www.joshwcomeau.com/nextjs/refreshing-server-side-props/ | |
| router.refresh() |
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 axiosInstance: AxiosInstance = axios.create({ | |
| baseURL: API_URI, | |
| paramsSerializer: (params) => { | |
| return qs.stringify(params, { arrayFormat: 'brackets' }) | |
| }, | |
| }) |
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, { useMemo, useRef, useState } from 'react'; | |
| import { Text, TextProps, Tooltip } from '@chakra-ui/react'; | |
| const LongText = (props: TextProps) => { | |
| const ref = useRef<HTMLParagraphElement>(null); | |
| const [showShowTooltip, setShowShowTooltip] = useState(false); | |
| const shouldShowTooltip = useMemo(() => { | |
| if (ref.current) { | |
| return ref.current.scrollWidth > ref.current.clientWidth; |
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 TEXT_KATAKANA_REGEX = /^([ァ-ン]|ー|ヴ)*$/ | |
| export const HALF_WIDTH_NUMBER_REGEX = /^[0-9]+$/ | |
| export const FULL_WIDTH = '0123456789-'; | |
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
| {"lastUpload":"2017-09-07T05:02:40.607Z","extensionVersion":"v2.8.3"} |
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
| // connect() is a function that injects Redux-related props into your component. | |
| // You can inject data and callbacks that change that data by dispatching actions. | |
| function connect(mapStateToProps, mapDispatchToProps) { | |
| // It lets us inject component as the last step so people can use it as a decorator. | |
| // Generally you don't need to worry about it. | |
| return function (WrappedComponent) { | |
| // It returns a component | |
| return class extends React.Component { | |
| render() { | |
| return ( |
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
| // Javascript Coroutines | |
| var toggle = (function*(){ | |
| while(true) { | |
| yield true | |
| yield false | |
| } | |
| })(); | |
| for (var x = 0; x < 10; x++) { | |
| console.log(toggle.next().value) |
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
| // Javascript generator example. | |
| var sequence, sq; | |
| sq = function * (initialValue) { | |
| var current, num, step; | |
| num = initialValue || 2; | |
| step = 1; | |
| while (true) { | |
| current = num * step++; | |
| yield current; |
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
| // Javascript Singleton Pattern | |
| var mySingleton = (function() { | |
| var instance; | |
| function init() { | |
| function privateMethod() { | |
| console.log("I am private") | |
| } | |
| var privateVariable = "I am also private" | |
| var privateRandomNumber = Math.random() | |
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
| // Coercion type in javascript: | |
| var ToPrimitive; | |
| ToPrimitive = function (obj) { | |
| var funct, functions, val, _i, _len; | |
| functions = ["valueOf", "toString"]; | |
| if (typeof obj === "object") { | |
| if (obj instanceof Date) { | |
| functions = ["toString", "valueOf"]; |
NewerOlder