From c206a4fbf76908c45dceb9254893846d22186971 Mon Sep 17 00:00:00 2001 From: Dmitry Komalov Date: Tue, 13 Mar 2018 16:49:13 +0400 Subject: [PATCH 1/2] implementing number of bubbles in props --- src/Bubbles.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Bubbles.js b/src/Bubbles.js index f613659..71ce9f6 100644 --- a/src/Bubbles.js +++ b/src/Bubbles.js @@ -9,21 +9,21 @@ export default class Bubbles extends Component { static propTypes = { size: PropTypes.number, color: PropTypes.string, - spaceBetween: PropTypes.number + spaceBetween: PropTypes.number, + bubblesCount: PropTypes.number }; static defaultProps = { spaceBetween: 6, size: 11, - color: '#000' + color: '#000', + bubblesCount: 3 }; + circles = [].legnth = bubblesCount; + state = { - circles: [ - new Animated.Value(0), - new Animated.Value(0), - new Animated.Value(0) - ] + circles: this.circles.map(() => new Animated.Value(0)) }; componentDidMount() { @@ -84,9 +84,7 @@ export default class Bubbles extends Component { const height = size * 2; return ( - {this.renderBubble(0)} - {this.renderBubble(1)} - {this.renderBubble(2)} + {this.circles.map((item, index) => this.renderBubble(index))} ); } } From 219cb1a073042dff70a49fb41bd008f687ac5360 Mon Sep 17 00:00:00 2001 From: Dmitry Komalov Date: Tue, 13 Mar 2018 16:58:39 +0400 Subject: [PATCH 2/2] grammar fix --- src/Bubbles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bubbles.js b/src/Bubbles.js index 71ce9f6..9c5b142 100644 --- a/src/Bubbles.js +++ b/src/Bubbles.js @@ -20,7 +20,7 @@ export default class Bubbles extends Component { bubblesCount: 3 }; - circles = [].legnth = bubblesCount; + circles = [].length = bubblesCount; state = { circles: this.circles.map(() => new Animated.Value(0))