refactor(background): allow multiple types #10

This commit is contained in:
moklick
2019-10-08 18:47:18 +02:00
parent f0f10b667c
commit 77faa369d4
6 changed files with 72 additions and 19 deletions
+27
View File
@@ -0,0 +1,27 @@
import React, { memo } from 'react';
import PropTypes from 'prop-types';
import Grid from './Grid';
const bgComponents = {
grid: Grid
};
const BackgroundRenderer = memo(({
backgroundType, ...rest
}) => {
const BackgroundComponent = bgComponents[backgroundType];
return <BackgroundComponent {...rest} />
});
BackgroundRenderer.displayName = 'BackgroundRenderer';
BackgroundRenderer.propTypes = {
backgroundType: PropTypes.oneOf(['grid'])
};
BackgroundRenderer.defaultProps = {
backgroundType: 'grid'
};
export default BackgroundRenderer;