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

Remove prop-types #56

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
presets: [['@babel/env', { modules: false, loose: true }], '@babel/react'],
plugins: [
['@babel/proposal-class-properties', { loose: true }],
['transform-react-remove-prop-types', { mode: 'unsafe-wrap' }],
// used for stripping out the `invariant` messages in production builds
'dev-expression',
],
Expand Down
30 changes: 15 additions & 15 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"dist/index.umd.js": {
"bundled": 7929,
"minified": 3508,
"gzipped": 1448
"bundled": 7615,
"minified": 3339,
"gzipped": 1383
},
"dist/index.min.js": {
"bundled": 7634,
"minified": 3305,
"gzipped": 1360
"bundled": 7485,
"minified": 3226,
"gzipped": 1333
},
"dist/index.cjs.js": {
"bundled": 6568,
"minified": 3814,
"gzipped": 1318
"bundled": 6278,
"minified": 3563,
"gzipped": 1266
},
"dist/index.esm.js": {
"bundled": 6160,
"minified": 3486,
"gzipped": 1227,
"bundled": 5890,
"minified": 3250,
"gzipped": 1172,
"treeshaked": {
"rollup": {
"code": 439,
"import_statements": 403
"code": 420,
"import_statements": 384
},
"webpack": {
"code": 1670
"code": 1616
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"babel-eslint": "^8.2.6",
"babel-jest": "^23.4.2",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.14",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
Expand All @@ -68,7 +67,6 @@
"lint-staged": "^7.1.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.12.1",
"prop-types": "^15.6.2",
"raf": "^3.4.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
Expand All @@ -86,7 +84,6 @@
"tiny-invariant": "^1.0.0"
},
"peerDependencies": {
"prop-types": ">=15",
"react": ">=16.3",
"react-dom": ">=16.3"
},
Expand Down
10 changes: 2 additions & 8 deletions src/HeadProvider.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import invariant from 'tiny-invariant';
import { Provider } from './context';

const cascadingTags = ['title', 'meta'];

export default class HeadProvider extends React.Component {
static propTypes = {
headTags: PropTypes.array,
children: PropTypes.node.isRequired,
};

indices = new Map();

state = {
Expand Down Expand Up @@ -73,8 +67,8 @@ export default class HeadProvider extends React.Component {

render() {
invariant(
typeof window !== 'undefined' || this.props.headTags,
'headTags should be passed to <HeadProvider /> in node'
typeof window !== 'undefined' || Array.isArray(this.props.headTags),
'headTags array should be passed to <HeadProvider /> in node'
);
return <Provider value={this.state}>{this.props.children}</Provider>;
}
Expand Down
5 changes: 0 additions & 5 deletions src/HeadTag.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import invariant from 'tiny-invariant';
import { Consumer } from './context';

export default class HeadTag extends React.Component {
static propTypes = {
tag: PropTypes.string.isRequired,
};

state = {
canUseDOM: false,
};
Expand Down
12 changes: 11 additions & 1 deletion tests/ssr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ describe('head tag during server', () => {
<Style>{`body {}`}</Style>
</HeadProvider>
);
}).toThrowError(/headTags should be passed/);
}).toThrowError(/headTags array should be passed/);
});

it('fails if headTags is not an array', () => {
expect(() => {
renderToStaticMarkup(
<HeadProvider headTags={{}}>
<Style>{`body {}`}</Style>
</HeadProvider>
);
}).toThrowError(/headTags array should be passed/);
});

it('throw error if head tag is rendered without HeadProvider', () => {
Expand Down