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

Replace usage of defaultProps #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions src/html.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const usedProps = Object.keys(defaultProps)
class HTMLEllipsis extends React.Component {
constructor (props) {
super(props)
this.props = { ...defaultProps, ...props }
this.state = {
html: props.unsafeHTML,
clamped: false
Expand Down Expand Up @@ -240,6 +241,4 @@ class HTMLEllipsis extends React.Component {
}
}

HTMLEllipsis.defaultProps = defaultProps

export default HTMLEllipsis
3 changes: 1 addition & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const usedProps = Object.keys(defaultProps)
class LinesEllipsis extends React.Component {
constructor (props) {
super(props)
this.props = { ...defaultProps, ...props }
this.state = {
text: props.text,
clamped: false
Expand Down Expand Up @@ -185,6 +186,4 @@ class LinesEllipsis extends React.Component {
}
}

LinesEllipsis.defaultProps = defaultProps

export default LinesEllipsis
18 changes: 9 additions & 9 deletions src/loose.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React from 'react'

function LinesEllipsisLoose (props) {
const { component: Component, text, lineHeight, maxLine, style, overflowFallback, ...rest } = props
function LinesEllipsisLoose ({
component: Component = 'div',
text,
lineHeight,
maxLine = 1,
style = {},
overflowFallback = true,
...rest
}) {
const maxLineNumber = +maxLine || 1
let usedStyle = {
...style,
Expand All @@ -28,11 +35,4 @@ function LinesEllipsisLoose (props) {
)
}

LinesEllipsisLoose.defaultProps = {
component: 'div',
maxLine: 1,
style: {},
overflowFallback: true
}

export default LinesEllipsisLoose
9 changes: 6 additions & 3 deletions src/responsiveHOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import React from 'react'
import debounce from 'lodash/debounce'
const isBrowser = typeof window !== 'undefined'

const defaultProps = {
innerRef: () => {}
}

export default function responsiveHOC (wait = 150, debounceOptions) {
return Component => {
class Responsive extends React.Component {
constructor (props) {
super(props)
this.props = { ...defaultProps, ...props }
this.state = {
winWidth: isBrowser ? window.innerWidth : 0
}
Expand Down Expand Up @@ -35,9 +40,7 @@ export default function responsiveHOC (wait = 150, debounceOptions) {
}

Responsive.displayName = `Responsive(${Component.displayName || Component.name})`
Responsive.defaultProps = {
innerRef () {}
}

return Responsive
}
}