Skip to content

[react-performance-testing] You have anonymous component. If your component don't have display name, we can not set property to renderCount.current  #28

@jojonarte

Description

@jojonarte

Warning shows even if displayName explicitly set already.

  describe('KeyboardAccessibilityContext - rerenders', () => {
    it('render count should be one', async () => {
      function MockContextConsumerComponent() {
        const { setVisible, visible } = useKeyboardAccessibilityContext()

        return (
          <Button
            title="Test btn"
            testID="btn"
            onPress={() => setVisible(!visible)}
          />
        )
      }
      MockContextConsumerComponent.displayName = 'MockContextConsumerComponent'
      const useKeyboardAccessibilityHookReturnValue = {
        setVisible: jest.fn(() => null),
        visible: false,
      }
      function MockContextScenario() {
        return (
          <KeyboardAccessibilityProvider
            useKeyboardAccessibilityHook={() =>
              useKeyboardAccessibilityHookReturnValue
            }
          >
            <MockContextConsumerComponent />
          </KeyboardAccessibilityProvider>
        )
      }
      MockContextScenario.displayName = 'MockContextScenario'

      const { renderCount } = perf(React)

      const { getByTestId } = render(<MockContextScenario />)

      fireEvent.press(getByTestId('btn'))

      await wait(() => {
        expect(renderCount.current.MockContextScenario.value).toBe(1)
      })
    })
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions