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

Added failing test check for Route and forwardRef #6384

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/react-router/modules/__tests__/Route-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,37 @@ describe("A <Route>", () => {
expect(typeof props.location).toBe("object");
expect(typeof props.match).toBe("object");
});

it("won't throw a prop-type warning when passed valid React components that aren't functions", () => {
function forwardRef(Component) {
class ForwardComponent extends React.Component {
render() {
const { forwardedRef, ...rest } = this.props;
return <Component ref={forwardedRef} {...rest} />;
}
}

return React.forwardRef((props, ref) => {
return <ForwardComponent {...props} forwardedRef={ref} />;
});
}

const history = createHistory();

const Component = () => null;
const WrappedComponent = forwardRef(Component);

const errorSpy = jest.spyOn(console, "error");

ReactDOM.render(
<Router history={history}>
<Route path="/" component={WrappedComponent} />
</Router>,
node
);

expect(errorSpy).not.toHaveBeenCalled();
});
});

describe("the `render` prop", () => {
Expand Down