Skip to content

Commit

Permalink
Remove dependency on create-react-class
Browse files Browse the repository at this point in the history
- remove createClass export from src/react-compat
- add test/react-compat with createClass export
- change spec files to import createClass from test/react-compat
- undo changes to src/ReactWrapperComponent.jsx (use of createClass there removed in enzymejs#877
- update README with correct dependencies for react@15.5
  • Loading branch information
nfcampos committed Apr 10, 2017
1 parent f736f3c commit 107e2e6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ If you are using `React >=15.5`, in addition to `enzyme`, you will have to ensur
the following npm modules installed if they were not already:

```bash
npm i --save-dev react-dom create-react-class
npm i --save-dev react-test-renderer react-dom
```


Expand Down
4 changes: 1 addition & 3 deletions src/ReactWrapperComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import React, { PropTypes } from 'react';
import objectAssign from 'object.assign';
import { createClass } from './react-compat';

/* eslint react/forbid-prop-types: 0 */

Expand Down
9 changes: 0 additions & 9 deletions src/react-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ let childrenToArray;
let renderWithOptions;
let unmountComponentAtNode;
let batchedUpdates;
let createClass;
let shallowRendererFactory;

const React = require('react');
Expand Down Expand Up @@ -177,13 +176,6 @@ if (REACT013) {
};
}

if (REACT155) {
// eslint-disable-next-line import/no-extraneous-dependencies
createClass = require('create-react-class');
} else {
createClass = React.createClass;
}

function isDOMComponentElement(inst) {
return React.isValidElement(inst) && typeof inst.type === 'string';
}
Expand Down Expand Up @@ -219,5 +211,4 @@ export {
renderWithOptions,
unmountComponentAtNode,
batchedUpdates,
createClass,
};
3 changes: 2 additions & 1 deletion test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
import sinon from 'sinon';
import { batchedUpdates, createClass } from '../src/react-compat';
import { batchedUpdates } from '../src/react-compat';
import { createClass } from './react-compat'

import {
describeWithDOM,
Expand Down
2 changes: 1 addition & 1 deletion test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { expect } from 'chai';
import sinon from 'sinon';

import { createClass } from '../src/react-compat';
import { createClass } from './react-compat';
import { shallow, render, ShallowWrapper } from '../src/';
import { describeIf, itIf, itWithData, generateEmptyRenderData } from './_helpers';
import { ITERATOR_SYMBOL, withSetStateAllowed } from '../src/Utils';
Expand Down
14 changes: 14 additions & 0 deletions test/react-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { REACT155 } from './version';

let createClass;

if (REACT155) {
// eslint-disable-next-line import/no-extraneous-dependencies
createClass = require('create-react-class');
} else {
createClass = require('react').createClass;
}

export {
createClass,
};
2 changes: 1 addition & 1 deletion test/staticRender-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect } from 'chai';
import { describeWithDOM, describeIf } from './_helpers';
import { render } from '../src/';
import { REACT013 } from '../src/version';
import { createClass } from '../src/react-compat';
import { createClass } from './react-compat'

describeWithDOM('render', () => {
describeIf(!REACT013, 'context', () => {
Expand Down

0 comments on commit 107e2e6

Please sign in to comment.