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

Animation not working when isVotedId is passed #38

Open
CodeMasterZeroOne opened this issue Dec 6, 2022 · 2 comments
Open

Animation not working when isVotedId is passed #38

CodeMasterZeroOne opened this issue Dec 6, 2022 · 2 comments

Comments

@CodeMasterZeroOne
Copy link

CodeMasterZeroOne commented Dec 6, 2022

Hi,

Great package!
I just have one but.
When I set isVoted={true} and isVotedId={0} animation with the green bar does not work but isVoted is working as the input is blocked.
Any idea why that happens?

here is my code:

<LeafPoll
type='multiple'
question='Who grows the best "Movember Moustache"? Please vote now.'
results={candidates}
theme={customTheme}
onVote={vote}
isVoted={true}
isVotedId={1}
// isVoted={userVoted.isVoted}
// isVotedId={userVoted.isVotedId}
/>

Error:
reactLeafPolls

TIA

@josefheld
Copy link

josefheld commented May 8, 2023

Hi, i got a similar error.
Has your object "candidates" an id field?

Your object should look like this:
[ {id: 1, text:"Freddy", votes: 4, percentage: 25} {id: 2, text:"Herbert", votes: 0, percentage: 0} {id: 3, text:"Timmy", votes: 8, percentage: 50} {id: 4, text:"Robert", votes: 4, percentage: 25} ]

@nicolaskn
Copy link

The problem is the ref for the object is different than when you populate data using setstate, which is why if you pass static(mock) data to the leaf poll it works as expected.

This easiest solution for me was calling my API first then rendering the LeafPoll element. This fixed the error above and also the other issue related to already voted and voted choice.

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

No branches or pull requests

3 participants