I'm not sure a HoC for hooks is a good idea, but it seemed fun to build. Also, it may come in handy when adding new code to old components.
export default connectHooks([
{
hook: useFetch,
hookArgs: ["https://swapi.co/api/people/1"],| [ | |
| { | |
| "id": "bierner.lit-html", | |
| "name": "lit-html", | |
| "publisher": "bierner", | |
| "version": "1.11.1" | |
| }, | |
| { | |
| "id": "bradgashler.htmltagwrap", | |
| "name": "htmltagwrap", |
| [core] | |
| excludesfile = /Users/juliettepretot/.gitignore_global | |
| editor = code -n -w | |
| ignorecase = false | |
| [commit] | |
| template = /Users/juliettepretot/.stCommitMsg | |
| [push] | |
| default = current | |
| [diff] | |
| tool = default-difftool |
| import { useState, useEffect } from 'react' | |
| // Use this hook to quickly read whether a component is being rendered server | |
| // side or client-side. This can be helpful when building components that are | |
| // intended to work without client-side JavaScript. | |
| // Use like: | |
| // const isMounted = useIsMounted() | |
| const useIsMounted = () => { |
| function fish_prompt | |
| set -l last_status $status | |
| set -l cyan (set_color -o cyan) | |
| set -l yellow (set_color -o yellow) | |
| set -l red (set_color -o AE111D) | |
| set -l blue (set_color -o blue) | |
| set -l green (set_color -o green) | |
| if not set -q __fish_git_prompt_show_informative_status | |
| set -g __fish_git_prompt_show_informative_status 1 |
| import React from 'react' | |
| import { render } from 'react-dom' | |
| /* | |
| The goal of this hook is to provide an alternative to using indexes as | |
| keys in react. Instead, what if we could use the object references as keys. | |
| Since React only accepts strings as keys, let's associate string keys to | |
| object references. |
I hereby claim:
To claim this, I am signing this object:
| describe('The `mergeTwoSortedArrays` function', () => { | |
| it('merges two sorted arrays', async () => { | |
| expect(mergeTwoSortedArrays([1, 3, 5, 7], [2, 4, 6, 8, 10])).toEqual([ | |
| 1, | |
| 2, | |
| 3, | |
| 4, | |
| 5, | |
| 6, | |
| 7, |
| #!/usr/bin/env python3 | |
| """ | |
| Complete Akuvox login + refresh + door open workflow. | |
| Example: | |
| python3 scripts/akuvox_refresh_and_open.py --country-code 1 --phone 2121239876 --subdomain ucloud --sms-code 123456 | |
| Steps performed: | |
| 1. Resolve the regional REST host and send `sms_login` with the supplied code. | |
| 2. Rotate the session token three times using the refresh API. |
| name | enum-driven-state |
|---|---|
| description | Enforce enum-driven, type-safe state modeling so invalid states are unrepresentable; refactor boolean flags/"isX" helpers and conditional-only fields into enum cases with associated data. |
Use this skill when a codebase shows boolean flags, optional fields, or "only valid for X" comments that can be expressed as an enum with associated data. The goal is to make invalid states impossible to represent and to update call sites to match enum cases directly.