Skip to content

Commit

Permalink
Merge pull request #526 from testing-library/bugfix/beta-pure-typeerror
Browse files Browse the repository at this point in the history
fix: ReactHooksRenderer renderHook was not expecting arguments
  • Loading branch information
joshuaellis authored Jan 7, 2021
2 parents a3fd0e2 + 9bab184 commit f6096ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CreateRenderer, Renderer, RenderResult, RenderHook } from '../types'
import { ResultContainer, RenderHookOptions } from '../types/internal'
import { CreateRenderer, Renderer, RenderResult, RenderHook, RenderHookOptions } from '../types'
import { ResultContainer } from '../types/internal'

import asyncUtils from './asyncUtils'
import { cleanup, addCleanup, removeCleanup } from './cleanup'
Expand Down
9 changes: 8 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ export type RenderHook<
AsyncUtils

export interface ReactHooksRenderer {
renderHook: <TProps, TResult>() => RenderHook<TProps, TResult>
renderHook: <TProps, TResult, TOptions>(
callback: (props: TProps) => TResult,
options?: RenderHookOptions<TProps, TOptions>
) => RenderHook<TProps, TResult>
act: Act
cleanup: () => void
addCleanup: (callback: () => Promise<void> | void) => () => void
removeCleanup: (callback: () => Promise<void> | void) => void
}

export type RenderHookOptions<TProps, TOptions extends {}> = TOptions & {
initialProps?: TProps
}

export interface Act {
(callback: () => void | undefined): void
(callback: () => Promise<void | undefined>): Promise<undefined>
Expand Down
4 changes: 0 additions & 4 deletions src/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ export type ResultContainer<TValue> = {
setValue: (val: TValue) => void
setError: (error: Error) => void
}

export type RenderHookOptions<TProps, TOptions extends {}> = TOptions & {
initialProps?: TProps
}

0 comments on commit f6096ba

Please sign in to comment.