React Native中的displayName属性:无法设置它,React Native抛出

时间:2018-06-07 09:25:56

标签: reactjs react-native

当我尝试按照React网络版本的方式设置displayName属性时出现此错误。

  

尝试分配给只读属性

enter image description here

RN中是否存在?怎么设置呢?这就是我设置它的方式:

import React, { Component } from 'react'; 
class Foo extends Component {
    render() { ... }
    static get displayName() {
        return 'Foo'
    }
}

// This works well. I wounder why static get above doesn't work though
Foo.displayName = 'Foo';

React Native GitHub中有一个关于它的问题https://github.com/facebook/react-native/issues/1715#issuecomment-114291624 他们建议如下。但这是什么意思,react.displayName添加到白名单

  

这是由于babel / babel#1761将反应变换器拆分为react和react.displayName以修复displayName属性插入的优先级问题。将react.displayName添加到白名单应该解决这个问题。

0 个答案:

没有答案