Using ReactCSSTransitionGroup with TypeScript

I wanted to use ReactCSSTransitionGroup to add a little animation to a React and TypeScript project I was working on.

Following the docs:

import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; // ES6

Seems ok. But on doing this, in my .tsx  file, I ended up with a compilation error:

Failed to compile.

/path/to/my/src/Home/Home.tsx
(2,8): Module '"/path/to/my/node_modules/@types/react-addons-css-transition-group/index"' has no default export.

The fix to this came to me, as I’d read this somewhere previously a few months ago when doing my original exploration of TypeScript.

The syntax I really needed was:

import * as ReactCSSTransitionGroup from 'react-addons-css-transition-group';

I honestly can’t remember where I first read this. But hopefully I can at least pass a helpful little tip on to you.

Shares

Published by

Code Review

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

One thought on “Using ReactCSSTransitionGroup with TypeScript”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.