Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jojonarte opened this issue Oct 2, 2021 · 2 comments

Comments

@jojonarte
Copy link

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)
      })
    })
  })
@keiya01
Copy link
Owner

keiya01 commented Oct 11, 2021

Could you create codesandbox?

@jojonarte
Copy link
Author

okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants