To check what the real type of and variable, run this command:
Object.prototype.toString.call(myVar)It'll return something like [object Object]. The second word is the real type of the variable.
Some examples:
To check what the real type of and variable, run this command:
Object.prototype.toString.call(myVar)It'll return something like [object Object]. The second word is the real type of the variable.
Some examples:
You could define a ref, and then inside the object, make multiple subvalues based on the key of the child:
const ref = useRef({})
{array.map((item)=><div key={item.id} ref={ref.current[item.id] ??= { current: null }}>{item.id}</div>)}
Example: https://playcode.io/1096173
Another approach is callback refs:
| #!/bin/bash | |
| lightMode="'prefer-light'" | |
| darkMode="'prefer-dark'" | |
| ligthTheme="'Adwaita'" | |
| darkTheme="'Adwaita-dark'" | |
| function toggleMode { |
| #!/bin/bash | |
| echo 'Removing origins...' | |
| git remote prune origin | |
| BRANCHES=`git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}'` | |
| if [[ `echo -e "$BRANCHES" | wc -w` -gt 0 ]]; then | |
| echo 'Removing branches:' | |
| echo $BRANCHES |
| declare type DeepPartial<T> = { | |
| [K in keyof T]?: DeepPartial<T[K]> | undefined | |
| } | |
| const isObject = (obj: unknown) => obj && typeof obj === 'object' | |
| /** | |
| * Patch source object with other object. | |
| * Only the source object keys are kept! | |
| * Patch undefined values are ignored |
| declare type StringfyKeys<T> = | |
| T extends Record<string, unknown> ? `${keyof T}` : never | |
| declare type NonNullableFields<T> = { | |
| [P in keyof T]: NonNullable<T[P]> | |
| } | |
| declare type NonNullableField<T, K extends keyof T> = T & | |
| NonNullableFields<Pick<T, K>> |
| /** | |
| * execute a callback and return an result/error array | |
| * | |
| * @param {callback} function to be executed | |
| */ | |
| export const safePromise = async <TData, TError>( | |
| callback: () => Promise<TData> | |
| ): Promise<[false, TError, undefined] | [true, undefined, TData]> => { | |
| try { | |
| const response: TData = await callback() |
| # Make Tab autocomplete regardless of filename case | |
| set completion-ignore-case on | |
| # List all matches in case multiple possible completions are possible | |
| set show-all-if-ambiguous on | |
| # Immediately add a trailing slash when autocompleting symlinks to directories | |
| set mark-symlinked-directories on | |
| # Use the text that has already been typed as the prefix for searching through |