Skip to content

Commit

Permalink
Removes prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed Jan 15, 2020
1 parent 2a52e60 commit 162af93
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ Use it via the render prop pattern (supports `children` or `render` prop):
import { SizeMe } from 'react-sizeme'

function MyApp() {
return (
<SizeMe>
{({ size }) => <div>My width is {size.width}px</div>}
</SizeMe>
)
return <SizeMe>{({ size }) => <div>My width is {size.width}px</div>}</SizeMe>
}
```

Expand Down Expand Up @@ -269,7 +265,6 @@ Should you wish to avoid the render of a placeholder and have an eager render of

```javascript
import React from 'react';
import PropTypes from 'prop-types';
import LargeChildComponent from './LargeChildComponent';
import SmallChildComponent from './SmallChildComponent';
import sizeMe from 'react-sizeme';
Expand All @@ -288,12 +283,6 @@ function MyComponent(props) {
</div>
);
}
MyComponent.propTypes = {
size: PropTypes.shape({
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
})
}

export default sizeMe({ monitorHeight: true })(MyComponent);
```
Expand Down
8 changes: 2 additions & 6 deletions src/component.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/* eslint-disable react/prop-types */

import React, { Component } from 'react'
import isShallowEqual from 'shallowequal'
import PropTypes from 'prop-types'
import withSize from './with-size'

export default class SizeMe extends Component {
static propTypes = {
children: PropTypes.func,
render: PropTypes.func,
}

static defaultProps = {
children: undefined,
render: undefined,
Expand Down
24 changes: 1 addition & 23 deletions src/with-size.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable react/no-multi-comp */
/* eslint-disable react/prop-types */
/* eslint-disable react/require-default-props */
/* eslint-disable react/no-find-dom-node */

import React, { Children, Component } from 'react'
import PropTypes from 'prop-types'
import ReactDOM from 'react-dom'
import invariant from 'invariant'
import { debounce, throttle } from 'throttle-debounce'
Expand Down Expand Up @@ -38,7 +38,6 @@ class ReferenceWrapper extends Component {
return Children.only(this.props.children)
}
}
ReferenceWrapper.propTypes = { children: PropTypes.element.isRequired }

function Placeholder({ className, style }) {
// Lets create the props for the temp element.
Expand All @@ -60,10 +59,6 @@ function Placeholder({ className, style }) {
return <div {...phProps} />
}
Placeholder.displayName = 'SizeMePlaceholder'
Placeholder.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
}

/**
* As we need to maintain a ref on the root node that is rendered within our
Expand Down Expand Up @@ -112,19 +107,6 @@ const renderWrapper = WrappedComponent => {
WrappedComponent,
)})`

SizeMeRenderer.propTypes = {
explicitRef: PropTypes.func.isRequired,
className: PropTypes.string,
style: PropTypes.object, // eslint-disable-line react/forbid-prop-types
size: PropTypes.shape({
width: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
height: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
position: PropTypes.object,
}),
disablePlaceholder: PropTypes.bool,
onSize: PropTypes.func,
}

return SizeMeRenderer
}

Expand Down Expand Up @@ -178,10 +160,6 @@ function withSize(config = defaultConfig) {
class SizeAwareComponent extends React.Component {
static displayName = `SizeMe(${getDisplayName(WrappedComponent)})`

static propTypes = {
onSize: PropTypes.func,
}

domEl = null

state = {
Expand Down

0 comments on commit 162af93

Please sign in to comment.