question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript errror: Type '(props: { newHeight: number; }) => void' is not assignable to type '(event: AnimationEvent<HTMLDivElement>) => void

See original GitHub issue

Code example

<AnimateHeight
    duration={300}
    height={childrenHeight}
    onAnimationStart={(props: { newHeight: number }) =>
        handleAnimationStart(props.newHeight)
    }
>

Expected behavior Typescript error Type '(props: { newHeight: number; }) => void' is not assignable to type '(event: AnimationEvent<HTMLDivElement>) => void:

Capture d’écran de 2019-12-23 15-55-52

Possible Solution

Remove & HTMLAttributes<HTMLDivElement> ?

export type AnimateHeightProps = {
  animateOpacity?: boolean;
  animationStateClasses?: AnimationStateClasses;
  applyInlineTransitions?: boolean;
  children: ReactNode | ReactNode[];
  className?: string;
  contentClassName?: string;
  delay?: number;
  duration?: number;
  easing?: "ease" | "linear" | "ease-in" | "ease-out" | "ease-in-out" | string;
  height?: string | number;
  onAnimationEnd?(props: { newHeight: number }): void;
  onAnimationStart?(props: { newHeight: number }): void;
  style?: CSSProperties;
} & HTMLAttributes<HTMLDivElement>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
remijeancommented, Jan 17, 2020

Ahah, thank you it works perfectly! 🔥

2reactions
Stankocommented, Jan 17, 2020

Dang! My bad again 🙈 Omit it is! I’ll try to get the new version out asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type 'void' is not assignable to type '((event: ChangeEvent ...
I assume you are not passing the event object into the handleChange method. This is how you should amend your onChange event handler:...
Read more >
type 'void' is not assignable to type 'reactnode'. - You.com
You just need to add data property to Row component props. import React, { PureComponent } from "react" ...
Read more >
Forms and Events - React TypeScript Cheatsheets
Event that occurs whenever a form or form element gets/loses focus, a form element value is changed or the form is submitted. InvalidEvent,...
Read more >
Type 'void' is not assignable to type '((event - JavaScript
JavaScript : Type ' void ' is not assignable to type '(( event : MouseEventHTMLInputElement) = void ) | undefined' [ Gift :...
Read more >
[Solved]-TypeScript error: Type 'void' is not assignable to type ...
[Solved]-TypeScript error: Type 'void' is not assignable to type 'SetStateAction<string>'-Reactjs. Search. score:0. //value type changes const ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found