Skip to content

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

@SamuelBageot

Description

@SamuelBageot

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions