Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using -1 as target element in useCountUp breaks in test #185

Closed
RobinBressan opened this issue Oct 3, 2019 · 3 comments · Fixed by #192
Closed

Using -1 as target element in useCountUp breaks in test #185

RobinBressan opened this issue Oct 3, 2019 · 3 comments · Fixed by #192

Comments

@RobinBressan
Copy link

Hi,

I'm trying to have storyshot running and my components using react-countup are breaking tests because countup.js try to set innerHTML on -1.

Maybe you should pass an empty litteral object in here:

const NO_ELEMENT = -1;

But not sure why this is triggering an error only in tests, it seems triggered inside react-test-renderer.

Do you have some feedback on this?

Thank you very much for your time and work!

@mmarkelov
Copy link
Collaborator

@RobinBressan I can take a look, but it will be helpful if you could provide your code, that breaking tests

@glennreyes
Copy link
Owner

glennreyes commented Oct 8, 2019

Maybe @reakaleek has an idea how to solve this? As far as I can remember can this be any truthy value that is not an actual element.

@reakaleek
Copy link
Collaborator

reakaleek commented Oct 8, 2019

Yeah, the -1 thing is obviously a hack. It was meant to avoid creating an element with document.createElement every time.
But we could actually create an element like once and just pass the same instance every time to fix this

or actually just pass { innerHTML: null }

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 a pull request may close this issue.

4 participants