Skip to content

_reactNative.renderHook is not a function #990

Description

@ggunti

Describe the bug

I get TypeError: (0 , _reactNative.renderHook) is not a function error.

Expected behavior

renderHook should be a function and work properly

Steps to Reproduce

This is what my Signin.test.js file contains:

import React from 'react';
import { useFormik } from 'formik';
import { render, fireEvent, renderHook } from '@testing-library/react-native';
import Signin from '../../../../src/modules/auth/components/Signin';
import CustomIntlProvider from '../../../__helpers__/CustomIntlProvider';

describe('Signin screen component', () => {
  test('signup function is called when the button is pressed', () => {
    const formik = renderHook(() =>
      useFormik({
        initialValues: { email: '', password: '' },
        onSubmit: jest.fn(),
        validateOnChange: false,
        validateOnBlur: false,
      }),
    );
    const signUp = jest.fn();
    const forgotPassword = jest.fn();
    const { getByText } = render(<Signin formik={formik} signUp={signUp} forgotPassword={forgotPassword} />, {
      wrapper: CustomIntlProvider,
    });
    expect(signUp).toHaveBeenCalledTimes(0);
    fireEvent.press(getByText('btn.signup'));
    expect(signUp).toHaveBeenCalledTimes(1);
  });
});

Screenshots

Captură de ecran din 2022-06-06 la 16 01 30

Versions

@testing-library/react-native: ^9.1.0 => 9.1.0 
react: 17.0.2 => 17.0.2 
react-native: 0.68.2 => 0.68.2 
react-test-renderer: 17.0.2 => 17.0.2 

Activity

  1. AugustinLF commented on Jun 8, 2022

    @AugustinLF
    Collaborator

    The version of RNTL with renderHook hasn't be released yet.

  2. ginnymin commented on Jun 18, 2022

    @ginnymin

    Anyone have any insight on when the next release will be? I'm also waiting on renderHook

  3. mdjastrzebski commented on Jun 22, 2022

    @mdjastrzebski
    Member

    @thymikee is there anything blocking the release? Seems like working 'renderHook' would be useful to many people.

  4. thymikee commented on Jun 23, 2022

    @thymikee
    Member

    There was a breaking change right before this feature and I reverted 9.2.0 which had renderHook. I've released v10 now

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