Skip to content

Conversation

@karljohansson85
Copy link

Previously, missing the mandatory dataLength prop resulted in the component
silently failing to add more content. This commit makes the issue more visible,
as the component will now throw an error after mounting if the dataLength prop
isn't provided.

@rajatsan
Copy link
Collaborator

@fooki, it would be great if you could also add a unit test for this change!

@karljohansson85
Copy link
Author

@rajatsan Sure, I'll look into it today!

@karljohansson85
Copy link
Author

hmm I'm not sure how to test this. the typescript interface Props ensures that dataLength must be specified. If I write a test with dataLength removed, then jest will complain:

error TS2741: Property 'dataLength' is missing in type '{ children: Element; loader: string; hasMore: false; next: () => void; }' but required in type 'Readonly'.

This is only visible in tests though, not when using the library in other projects.

@rajatsan
Copy link
Collaborator

You can use // @ts-ignore so that Typescript won't complain when you write that test.

@karljohansson85
Copy link
Author

Thanks for your help. I've added a test case now. Let me know if anything else is needed.

Previously, missing the mandatory dataLength prop resulted in the component
silently failing to add more content. This commit makes the issue more visible,
as the component will now throw an error after mounting if the dataLength prop
isn't provided.
@ankeetmaini ankeetmaini merged commit e899545 into ankeetmaini:master Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants