rn-base-components
Version:
Easy to create a component
32 lines (28 loc) • 843 B
JavaScript
import React, {memo} from 'react';
import styled from 'styled-components/native';
import KEY from './Key';
function AppView(props) {
const {children} = props;
return <AppViewComponent {...props}>{children}</AppViewComponent>;
}
export default memo(AppView);
const AppViewComponent = styled.View(props => {
const {KEY_WORD_SPACE, KEY_WORD_STYLE} = KEY;
const stylesObj = {};
delete props?.children;
delete props?.forwardedComponent;
delete props?.forwardedRef;
delete props?.theme;
for (const property in props) {
if (KEY_WORD_SPACE[property]) {
stylesObj[KEY_WORD_SPACE[property]] = props[property];
}
if (KEY_WORD_STYLE[property]) {
const objStyles = KEY_WORD_STYLE[property];
for (const key in objStyles) {
stylesObj[key] = objStyles[key];
}
}
}
return stylesObj;
});