当我尝试按照React网络版本的方式设置displayName
属性时出现此错误。
尝试分配给只读属性
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添加到白名单应该解决这个问题。