Skip to content

Commit 52acb10

Browse files
authored
Merge pull request #2 from alex-wilmer/react15
⬆️ React 15 + whitelist props on span, yarn.lock
2 parents 3d8126b + 9f1c1f1 commit 52acb10

File tree

3 files changed

+5210
-13
lines changed

3 files changed

+5210
-13
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
"eslint": "^1.6.0",
2121
"eslint-plugin-react": "^3.5.1",
2222
"gulp": "^3.9.0",
23-
"react": "^0.14.0",
24-
"react-component-gulp-tasks": "^0.7.6",
25-
"react-dom": "^0.14.0"
23+
"react-component-gulp-tasks": "^0.7.6"
2624
},
2725
"peerDependencies": {
28-
"react": "^0.14.0"
26+
"react": ">= 15",
27+
"react-dom": ">= 15"
2928
},
3029
"browserify-shim": {
3130
"react": "global:React"

src/ReactRotatingText.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ReactRotatingText extends React.Component {
2323
// save the timeouts so we can stop on unmount
2424
const timeout = setTimeout(loopingFunc, pause);
2525
this.timeouts.push(timeout);
26-
26+
2727
// prevent memory leak
2828
const maxTimeouts = 100;
2929
if (this.timeouts.length > maxTimeouts) {
@@ -36,10 +36,10 @@ class ReactRotatingText extends React.Component {
3636
const { output } = this.state;
3737
const { typingInterval } = this.props;
3838
const loopingFunc = this._type.bind(this, text, callback);
39-
39+
4040
// set the string one character longer
4141
this.setState({output: text.substr(0, output.length + 1)});
42-
42+
4343
// if we're still not done, recursively loop again
4444
if (output.length < text.length) {
4545
this._loop(loopingFunc, typingInterval);
@@ -52,10 +52,10 @@ class ReactRotatingText extends React.Component {
5252
const { output } = this.state;
5353
const { deletingInterval } = this.props;
5454
const loopingFunc = this._erase.bind(this, callback);
55-
55+
5656
// set the string one character shorter
5757
this.setState({output: output.substr(0, output.length - 1)});
58-
58+
5959
// if we're still not done, recursively loop again
6060
if (output.length !== 0) {
6161
this._loop(loopingFunc, deletingInterval);
@@ -77,16 +77,26 @@ class ReactRotatingText extends React.Component {
7777
});
7878
this._loop(loopingFunc, emptyPause);
7979
};
80-
80+
8181
type.bind(this)(items[index], () => {
8282
this._loop(erase.bind(this, nextWord), pause);
8383
});
8484
};
8585

8686
render() {
87-
const { color, cursor, ...other } = this.props;
87+
const {
88+
color,
89+
cursor,
90+
deletingInterval,
91+
emptyPause,
92+
items,
93+
pause,
94+
typingInterval,
95+
...other
96+
} = this.props;
97+
8898
return (
89-
<span style={{color: color}} {...other}>
99+
<span style={{ color }} {...other}>
90100
{ this.state.output }
91101
{ cursor ? <span className="react-rotating-text-cursor">|</span> : null }
92102
</span>
@@ -114,4 +124,4 @@ ReactRotatingText.defaultProps = {
114124
typingInterval: 50,
115125
};
116126

117-
export default ReactRotatingText;
127+
export default ReactRotatingText;

0 commit comments

Comments
 (0)