From 23cd7522d165269e74aafb46f8abd3bdf79dba8d Mon Sep 17 00:00:00 2001 From: Senthil Sivanath Date: Mon, 13 Jun 2016 15:30:07 +0530 Subject: [PATCH] Updated For React Native 0.27 Changed create class to component + state initialization change for RN 0.27 --- ProgressBar.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ProgressBar.js b/ProgressBar.js index 53dd792..027b110 100644 --- a/ProgressBar.js +++ b/ProgressBar.js @@ -1,11 +1,11 @@ -var React = require('react-native'); +import React,{Component} from 'react'; -var { +import { Animated, Easing, StyleSheet, View -} = React; +} from 'react-native'; var styles = StyleSheet.create({ background: { @@ -19,27 +19,28 @@ var styles = StyleSheet.create({ } }); -var ProgressBar = React.createClass({ +class ProgressBar extends Component{ + state:any + constructor(props){ + super(props); + this.state = {progress:new Animated.Value(0)} + } getDefaultProps() { return { style: styles, easing: Easing.inOut(Easing.ease), easingDuration: 500 }; - }, + } + - getInitialState() { - return { - progress: new Animated.Value(this.props.initialProgress || 0) - }; - }, componentDidUpdate(prevProps, prevState) { if (this.props.progress >= 0 && this.props.progress != prevProps.progress) { this.update(); } - }, + } render() { @@ -53,7 +54,7 @@ var ProgressBar = React.createClass({ ); - }, + } update() { Animated.timing(this.state.progress, { @@ -62,6 +63,6 @@ var ProgressBar = React.createClass({ toValue: this.props.progress }).start(); } -}); +} module.exports = ProgressBar;