Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Prevent re-rendering when chart props remain the same #5

Open
plourenco opened this issue Oct 20, 2020 · 0 comments
Open

Prevent re-rendering when chart props remain the same #5

plourenco opened this issue Oct 20, 2020 · 0 comments

Comments

@plourenco
Copy link
Member

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)
})
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant