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
| declare module 'react-table' { | |
| // TypeScript Version: 3.5 | |
| import { ReactNode, ComponentType, MouseEvent } from 'react'; | |
| /** | |
| * The empty definitions of below provides a base definition for the parts used by useTable, that can then be extended in the users code. | |
| * | |
| * @example | |
| * export interface TableOptions<D extends object = {}}> |
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
| function toJSON(node) { | |
| let propFix = { for: 'htmlFor', class: 'className' }; | |
| let specialGetters = { | |
| style: (node) => node.style.cssText, | |
| }; | |
| let attrDefaultValues = { style: '' }; | |
| let obj = { | |
| nodeType: node.nodeType, | |
| }; | |
| if (node.tagName) { |
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Highlighting elements example</title> | |
| </head> | |
| <body> |
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
| // Simplistic (probably most common) approach. | |
| // This approach assumes either that: | |
| // 1) passive effects are always run synchronously, after paint, or | |
| // 2) passive effects never attach handlers for bubbling events | |
| // If both of the above are wrong (as can be the case) then problems might occur! | |
| useEffect(() => { | |
| const handleDocumentClick = (event: MouseEvent) => { | |
| // It's possible that a "click" event rendered the component with this effect, | |
| // in which case this event handler might be called for the same event (as it bubbles). | |
| // In most scenarios, this is not desirable. |
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
| // when T is any|unknown, Y is returned, otherwise N | |
| type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N; | |
| // when T is never, Y is returned, otherwise N | |
| type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N; | |
| // when T is a tuple, Y is returned, otherwise N | |
| // valid tuples = [string], [string, boolean], | |
| // invalid tuples = [], string[], (string | number)[] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 text = css({ | |
| color: '$gray12', | |
| variants: { | |
| size: { | |
| // corrective letter-spacing and text-indent styles | |
| // should go here too, because they're determined by font-size. | |
| // You could also put line-height here too, if your devs prefer | |
| // a default line-height that works in some cases. But understand | |
| // that line-height is also a function of line-length, so the |
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
| # Reusable bash function you can add to your ~/.zshrc or ~/.bashrc file | |
| # | |
| # Usage: pkg-script start "node index.js" | |
| # | |
| function pkg-script () { | |
| echo $(jq --arg key "${1}" --arg val "${2}" '.scripts[$key]=$val' package.json) | jq . | > package.json | |
| } |
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 interface RetryConfig { | |
| timeout: number | |
| max: number | |
| } | |
| export const retryAction = ( | |
| fn: (...args: any[]) => Promise<any>, | |
| { timeout, max }: RetryConfig | |
| ): Promise<any | void> => { | |
| // Keep a count of the retries |