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

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

Description

@plourenco

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)
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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