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

[react-chartjs-2 / React hooks] setState not working with 3.2.0 #806

Closed
SamuelBageot opened this issue Oct 25, 2021 · 4 comments
Closed
Assignees

Comments

@SamuelBageot
Copy link

Hi,

I have some problems with react-chartjs-2 v3.2.0.

Consider this simple component which update the data :

const Dashboard = () => {
const [actualData, setActualData] = useState(allData.lineData);

const handleSwitchData = (e) => {
    setActualData(allData[e.target.value])
};

return (
    <div>
        <Line data={actualData} />
        <select onChange={handleSwitchData}>
            <option value="lineData">Months</option>
            <option value="lineData2">Weeks</option>
        </select>
    </div>
)

};

When toggling with the select, the state doesn't update.

This issue occurs only in v3.2.0 BUT not with v3.0.5.

Best regards

@dangreen
Copy link
Collaborator

@SamuelBageot Hi. Can you please provide full working reproduction of this issue (repo, codesansbox, ...)?

@dangreen dangreen self-assigned this Oct 25, 2021
@SamuelBageot
Copy link
Author

Here a quick repo.

https://github.com/SamuelBageot/chartjs

dangreen added a commit that referenced this issue Oct 26, 2021
dangreen added a commit that referenced this issue Oct 26, 2021
@dangreen
Copy link
Collaborator

@SamuelBageot Hi. Please try v3.3.0

@SamuelBageot
Copy link
Author

@dangreen Hi. Nice work, everything seems to be ok.

Thanks !

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

2 participants