weex-nuke
Version:
基于 Rax 、Weex 的高性能组件体系 ~~
45 lines (39 loc) • 953 B
JSX
/** @jsx createElement */
import { createElement, Component, PropTypes } from 'rax';
import { hairLine, borderSeperate } from 'nuke-helper';
import s from './styles';
const isWeex = typeof callNative === 'function';
class View extends Component {
styleFix(style) {
let result = {};
if (style) {
result = borderSeperate(style);
result = hairLine.fixBorder(result);
}
return result;
}
render() {
const { style, ...others } = this.props;
const fixedStyle = this.styleFix(style);
const nativeProps = {
...others,
style: fixedStyle,
};
if (isWeex) {
return <div {...nativeProps} />;
}
return <div {...this.props} style={[s.initial, fixedStyle]} />;
}
}
View.propTypes = {
style: PropTypes.any,
};
View.defaultProps = {
style: null,
};
View.contextTypes = {
androidConfigs: PropTypes.any,
compatibilityConfigs: PropTypes.any,
};
export default View;
;