Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use useAccordionToggle with Typescript? #4191

Closed
MadLord80 opened this issue Aug 6, 2019 · 2 comments · Fixed by #4228
Closed

How to use useAccordionToggle with Typescript? #4191

MadLord80 opened this issue Aug 6, 2019 · 2 comments · Fixed by #4228

Comments

@MadLord80
Copy link

MadLord80 commented Aug 6, 2019

Can you give me example how do it?

@taion
Copy link
Member

taion commented Aug 6, 2019

It's not currently in our TS defs. Feel free to add it.

@MadLord80
Copy link
Author

For me it work like this:

useAccordionToggle.d.ts:

declare function useAccordionToggle(eventKey: string, onSelect?: (e: T) => void): (e: T) => void
export default useAccordionToggle
index.d.ts:

+ export { default as useAccordionToggle } from './useAccordionToggle';

in code:

import * as RB from 'react-bootstrap'

function CustomToggle(props: {children: any, evenKey: string}) {
	const onSelect = RB.useAccordionToggle(props.evenKey, () => console.log('ok'))

	return (
		<RB.Button
			onClick={onSelect}
		>
			{props.children}
		</RB.Button>
	)
}

bpas247 added a commit that referenced this issue Aug 9, 2019
I'm not actually sure if this is correct, since we don't really
have a standardized way of writing unit tests for our TypeScript
types (other than dtslint and `types/simple.test.tsx`).

fixes #4191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants