Use Accordion's onTitleClick property according to the typings, which look like this
onTitleClick?: (event: React.MouseEvent<HTMLDivElement>, index: number | number[]) => void;
get a number or number[] as the second argument
got an object
0.78.2
馃憢 Thanks for opening your first issue here! If you're reporting a 馃悶 bug, please make sure you've completed all the fields in the issue template so we can best help.
We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
Can you update your codesandbox? It does not have any Accordion component on it
Sorry, I guess I forgot to save the sandbox! I'll update the description.
Cool. I'm not too familiar with TypeScript, but it's weird that on AccordionAccordion.js, onTitleClick is documented this way:
/**
* Called when a panel title is clicked.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All item props.
*/
This seems to be what's happening, as data's type in your code example is an object with the element's information.
the problem is that the type declared in the .d.ts file is incorrect and no longer matches the actual behavior. The code was changed without the typing being updated.
Makes sense, maybe the maintainers should know a little bit more about this
Thanks for report, will be fixed by #2568.
@layershifter it looks like there are a good number of TypeScript errors with this project. Any talk of converting the source code to TypeScript and generating the type definitions instead, so they're never out of sync?
This project will be never converted to TS as we have really huge codebase there. If you have issues with typings, fill free to open PR with fixes.