Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设计上的不合理地方 #4

Open
liyixing1 opened this issue Jan 12, 2020 · 0 comments
Open

设计上的不合理地方 #4

liyixing1 opened this issue Jan 12, 2020 · 0 comments

Comments

@liyixing1
Copy link

liyixing1 commented Jan 12, 2020

1.没必要使用DeviceEventEmitter,会造成性能的极大损耗
没理解错的话,您的RRCTopView是单例的,RRCTopView中定义一个INSTANCE
export default class RRCTopView extends Component {
static INSTANCE = false;

constructor(props) {
....
RRCTopView.INSTANCE = this;
}

static addAlert(element) {
let key = ++keyValue;
//这里不再通过DeviceEventEmitter.emit触发
RRCTopView.INSTANCE.addAlertToTopView({ key, element });
return key;
}
}

2.这样就可以去除componentWillMount和componentWillUnmount
就能兼容新版本的react native的 componentWillMount改名的尴尬了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant