react-dc-js
react-dc-js copied to clipboard
Prevent re-rendering when chart props remain the same
The props of a chart are set as dependencies of the useChart hook and shallow checked, causing them to be considered different in every side-effect. The following test represents the problem:
it('should not cause a re-render if props did not change', () => {
const chartFunc = chartMock()
chartFunc.foo = jest.fn()
const Chart = BaseChart(() => chartFunc, [baseMixin])
const { rerender } = render(<Chart foo="bar" />)
expect(chartFunc.foo).toHaveBeenCalledTimes(1)
rerender(<Chart foo="bar" />)
expect(chartFunc.foo).toHaveBeenCalledTimes(1)
})