Skip to content

PickerIOS and DatePickerIOs generate warnings about refs when mocked by jest #16045

@jmoutte

Description

@jmoutte

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 7.7.2
Yarn: Not Found
npm: 4.1.2
Watchman: 4.7.0
Xcode: Xcode 9.0 Build version 9A235
Android Studio: 2.3 AI-162.3934792

Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: 0.48.3 => 0.48.3

Steps to Reproduce

  1. Run the attached test with jest

Expected Behavior

No warning should be generated.

Actual Behavior

Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.
    
    Check the render method of `PickerIOS`.
        in Unknown (created by PickerIOS)
        in View (created by View)
        in View (created by PickerIOS)
        in PickerIOS

Reproducible Demo

import React from 'react';
import { PickerIOS } from 'react-native';
import renderer from 'react-test-renderer';

describe('StateLessMocks', () => {
  it('generates a warning', () => {
    const tree = renderer.create(<PickerIOS />).toJSON();
    expect(tree).toMatchSnapshot();
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions