Telegram Group & Telegram Channel
Управление типами кортежей

Предположим, у нас есть функция, которая возвращает кортеж, например, пользовательский хук:


function useBool(initialValue = false) {
const [state, setState] = React.useState(initialValue)

const handlers = React.useMemo(
() => ({
on: () => setState(true),
off: () => setState(false),
toggle: () => setState(s => !s),
reset: () => setState(initialValue),
}),
[initialValue],
)

return [state, handlers]
}

const result = useBool()



https://kyleshevlin.com/wrangling-tuple-types/

✍️ @React_lib



tg-me.com/React_lib/605
Create:
Last Update:

Управление типами кортежей

Предположим, у нас есть функция, которая возвращает кортеж, например, пользовательский хук:


function useBool(initialValue = false) {
const [state, setState] = React.useState(initialValue)

const handlers = React.useMemo(
() => ({
on: () => setState(true),
off: () => setState(false),
toggle: () => setState(s => !s),
reset: () => setState(initialValue),
}),
[initialValue],
)

return [state, handlers]
}

const result = useBool()



https://kyleshevlin.com/wrangling-tuple-types/

✍️ @React_lib

BY React


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/React_lib/605

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

A Telegram spokesman declined to comment on the bond issue or the amount of the debt the company has due. The spokesman said Telegram’s equipment and bandwidth costs are growing because it has consistently posted more than 40% year-to-year growth in users.

telegram from sg


Telegram React
FROM USA