aaron9000 / react-image-timeline

:calendar: An image-centric timeline component for React.js
http://aaron9000.github.io/react-image-timeline/
MIT License
86 stars 17 forks source link

Issue In Default Setup #8

Closed spina-a-d closed 5 years ago

spina-a-d commented 5 years ago

I followed a really default setup from the npm page to see how it worked, but I think there's an issue with how the date is parsed.

This simple code:

<Timeline events={[{
                date: Date.parse("2013-09-27"),
                text: "Sed leo elit, pellentesque sit amet congue quis, ornare nec lorem.",
                title: "Cairo, Egypt",
                imageUrl: "http://github.com/aaron9000/react-image-timeline/blob/master/src/assets/cairo.jpg?raw=true"
}]} />

Produces the error:

TypeError: e.getFullYear is not a function

I would suspect something is going wrong if this basic example fails.

spina-a-d commented 5 years ago

Update: I can get other date objects to work, so I think the example code just needs updating.

aaron9000 commented 5 years ago

Thank you! I will fix this weekend.

aaron9000 commented 5 years ago

What kind of date object did you pass?

I should probably add some validation and more helpful errors.

spina-a-d commented 5 years ago

@aaron9000 When I got the error I did the date as I showed in the above snippet. When I got it to work I think I did it with new Date('27-09-2013') or something similar instead. I can't confirm because I no longer have the code I was testing with.

aaron9000 commented 5 years ago

You are right. Date.parse() is not producing a date object.

aaron9000 commented 5 years ago

@spina-a-d closing now. I put out a new version of the package and addressed the incorrect setup instructions. Appreciate you taking the time to file an issue! 👍