forked from n4kz/react-native-material-textfield
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Proptypes error on react-native 0.69
- Loading branch information
1 parent
ec87fd9
commit 8b88da6
Showing
7 changed files
with
116 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,82 @@ | ||
import PropTypes from 'prop-types' | ||
import React, { PureComponent } from 'react' | ||
import { Animated, Text } from 'react-native' | ||
import PropTypes from 'prop-types'; | ||
import React, { PureComponent } from 'react'; | ||
import { Animated } from 'react-native'; | ||
import { TextPropTypes } from 'deprecated-react-native-prop-types'; | ||
|
||
import styles from './styles' | ||
import styles from './styles'; | ||
|
||
export default class Helper extends PureComponent { | ||
static propTypes = { | ||
title: PropTypes.string, | ||
error: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
style: Text.propTypes.style, | ||
style: TextPropTypes.style, | ||
baseColor: PropTypes.string, | ||
errorColor: PropTypes.string, | ||
focusAnimation: PropTypes.instanceOf(Animated.Value), | ||
} | ||
}; | ||
|
||
constructor(props) { | ||
super(props) | ||
super(props); | ||
|
||
let { error, focusAnimation } = this.props | ||
let { error, focusAnimation } = this.props; | ||
|
||
let opacity = focusAnimation.interpolate({ | ||
inputRange: [-1, -0.5, 0], | ||
outputRange: [1, 0, 1], | ||
extrapolate: 'clamp', | ||
}) | ||
}); | ||
|
||
this.state = { | ||
errored: !!error, | ||
opacity, | ||
} | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
let { focusAnimation } = this.props | ||
let { focusAnimation } = this.props; | ||
|
||
this.listener = focusAnimation.addListener(this.onAnimation.bind(this)) | ||
this.listener = focusAnimation.addListener(this.onAnimation.bind(this)); | ||
} | ||
|
||
componentWillUnmount() { | ||
let { focusAnimation } = this.props | ||
let { focusAnimation } = this.props; | ||
|
||
focusAnimation.removeListener(this.listener) | ||
focusAnimation.removeListener(this.listener); | ||
} | ||
|
||
onAnimation({ value }) { | ||
if (this.animationValue > -0.5 && value <= -0.5) { | ||
this.setState({ errored: true }) | ||
this.setState({ errored: true }); | ||
} | ||
|
||
if (this.animationValue < -0.5 && value >= -0.5) { | ||
this.setState({ errored: false }) | ||
this.setState({ errored: false }); | ||
} | ||
|
||
this.animationValue = value | ||
this.animationValue = value; | ||
} | ||
|
||
render() { | ||
let { errored, opacity } = this.state | ||
let { style, title, error, disabled, baseColor, errorColor } = this.props | ||
let { errored, opacity } = this.state; | ||
let { style, title, error, disabled, baseColor, errorColor } = this.props; | ||
|
||
let text = errored ? error : title | ||
let text = errored ? error : title; | ||
|
||
if (text == null) { | ||
return null | ||
return null; | ||
} | ||
|
||
let textStyle = { | ||
opacity, | ||
|
||
color: !disabled && errored ? errorColor : baseColor, | ||
} | ||
}; | ||
|
||
return <Animated.Text style={[styles.text, style, textStyle]}>{text}</Animated.Text> | ||
return ( | ||
<Animated.Text style={[styles.text, style, textStyle]}> | ||
{text} | ||
</Animated.Text> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.