2017-03-09 58 views
1

我遇到了错误:“ProgressBarAndroid不推荐使用,而是使用ActivityIndi​​cator”,但是当我转到docs时,它看起来并不是实际上不推荐使用。React Native - “ProgressBarAndroid is deprecated。Use ActivityIndi​​cator instead”

我使用

react-native-cli: 2.0.1 react-native: 0.40.0

enter image description here

这里是我当前的相关代码:

import React from 'react'; 
import { ProgressViewIOS, ProgressBarAndroid, Platform } from 'react-native'; 

export default function ProgressBar(props) { 

    if(Platform.OS === 'ios'){ 
    return (
     <ProgressViewIOS 
      progress={props.progress} 
      style={{height: 3}} 
      progressViewStyle={'bar'} 
      progressTintColor={props.progressTintColor} 
     /> 
    ) 
    }else if(Platform.OS === 'android'){ 
    return <ProgressBarAndroid styleAttr="Horizontal" progress={props.progress} /> 
    }else{ 
    console.log('NO PROGRESS') 
    return null 

    } 

} 

即使我指定styleAttr="Horizontal"(我认为应该设置不确定的为假)我在android中的进度条是不确定的(它只是继续移动)。这与我在iOS上看到的功能不同。 iOS按预期工作。

另一个错误说:“你是手动呼吁indeterminate道具上ProgressBarAndroid一个React.PropType验证功能,但是当你在我的代码看是不是这样的。我也不相信有第三方这样做由于项目较小,直到我实现了我还没有看到这个错误如上图所示:

enter image description here

任何帮助表示赞赏

回答

0

如果它警告你,这是不推荐使用,为什么不直接使用API它的建议?你有什么用例?你觉得有必要使用ProgressViewIOS而不是它被替换的组件? (特别是因为ActivityIndciator适用于iOS和Android)

要回答您的问题,它可能不会在文档中被弃用,但它警告您它已被弃用,以支持新的API。如果你愿意,你可以继续使用它,但是你不会得到任何更新,它可能在未来的版本中被删除。

+5

ActivityIndciator与ProgressBarAndroid不同,后者包装仅限Android的ProgressBar。我需要一个进度条而不是加载微调器。 – Turnipdabeets

+0

活动指示器在android上不起作用。 –

相关问题