Skip to content

Commit

Permalink
fix: rename hooks ReturnType to Output
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpolitov authored and juliencrn committed Oct 13, 2022
1 parent 1b7e89f commit cb47590
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/useBoolean/useBoolean.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Dispatch, SetStateAction, useCallback, useState } from 'react'

interface ReturnType {
interface UseBooleanOutput {
value: boolean
setValue: Dispatch<SetStateAction<boolean>>
setTrue: () => void
setFalse: () => void
toggle: () => void
}

function useBoolean(defaultValue?: boolean): ReturnType {
function useBoolean(defaultValue?: boolean): UseBooleanOutput {
const [value, setValue] = useState(!!defaultValue)

const setTrue = useCallback(() => setValue(true), [])
Expand Down
4 changes: 2 additions & 2 deletions src/useCounter/useCounter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Dispatch, SetStateAction, useState } from 'react'

interface ReturnType {
interface UseCounterOutput {
count: number
increment: () => void
decrement: () => void
reset: () => void
setCount: Dispatch<SetStateAction<number>>
}

function useCounter(initialValue?: number): ReturnType {
function useCounter(initialValue?: number): UseCounterOutput {
const [count, setCount] = useState(initialValue || 0)

const increment = () => setCount(x => x + 1)
Expand Down
4 changes: 2 additions & 2 deletions src/useLockedBody/useLockedBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useEffect, useState } from 'react'

import { useIsomorphicLayoutEffect } from '..'

type ReturnType = [boolean, (locked: boolean) => void]
type UseLockedBodyOutput = [boolean, (locked: boolean) => void]

function useLockedBody(initialLocked = false): ReturnType {
function useLockedBody(initialLocked = false): UseLockedBodyOutput {
const [locked, setLocked] = useState(initialLocked)

// Do the side effect before render
Expand Down
4 changes: 2 additions & 2 deletions website/src/components/layout/useSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { useEffect, useState } from 'react'

import { useMediaQuery, useTheme } from '@mui/material'

type ReturnType = [
type UseSidebarOutput = [
boolean,
{
openSidebar: () => void
closeSidebar: () => void
},
]

function useSidebar(): ReturnType {
function useSidebar(): UseSidebarOutput {
const { breakpoints } = useTheme()
const isMobile = useMediaQuery(breakpoints.down('lg'))
const [isOpen, setOpen] = useState(false)
Expand Down

0 comments on commit cb47590

Please sign in to comment.