[英]How to dynamically call a module in React Native
I would like to have a react native View dynamically added.我想动态添加一个反应原生视图。 This will be completely undetermined before calling.
这将在调用之前完全不确定。
import React, {Component} from 'react';
import {View} from 'react-native';
export default class HelloWorld extends Component {
render() {
return (
<View>{ /** add a component a view depending on paremeters passed into class in Props**/}</View>
);
}
}
Since this will be completely undetermined I am not sure how to call a module from another module without first importing it.由于这将完全不确定,我不确定如何在不先导入的情况下从另一个模块调用模块。
How can I go about it?我该怎么办?
Thank you all in advance.谢谢大家。
How to dynamically call a module in React Native如何在 React Native 中动态调用模块
import React, {Component} from 'react';
import {View} from 'react-native';
export default class HelloWorld extends Component {
render() {
let dynamicComponent = this.props.displayDynamicComponent ? <DynamicComponent /> : null;
return (
<View>{dynamicComponent}</View>
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.