Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.
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

@plourenco

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions