Closed rasmuskl closed 8 years ago
Thanks for this - I wonder, would it be better to add this line to the index.js component file instead?
module.exports.default = MasonryComponent;
It seems a bit odd to me to import *
when react-masonry-component is only a single export. This also has the added benefit of being backwards compatible.
I'm not too knowledgable on TypeScript though, so please let me know if I've missed something :-)
That's a great idea. I didn't want to intrude on how you do your exports, but it would feel more natural the other way for sure.
I made the changes locally, verified that everything still works and updated the pull request.
Thanks for the quick feedback.
My import now looks like this with the latest changes:
import Masonry from "react-masonry-component";
@afram Any chance of a new release with the changes? :-)
yeah, I was holding up to see if it is still compatible with the original TypeScript definitions. This version uses ComponentClass (which from what I can tell seems to be the base component) so should be OK.
This is released as 4.2.2
Sorry for the delay.
No problem. Thanks!
Fixed TypeScript typings.
Exporting as default actually creates an export named
default
. The JS code for the react-masonry-component doesn't do this, but setsmodule.export =
the output fromReact.createClass
, which is of typeComponentClass<PropType>
.When using the old typings as a default import in TypeScript:
You get this error on runtime:
With the new typings, importing like this (which is the TypeScript equivalent of the export from the module):
Works with no error.