Trying to set a component to a repeating background image of adiv
I have a pattern that is repeated throughout the website.
Simplified pattern components:
import React from 'react' import PropTypes from 'prop-types' import styled from 'styled-components' const Container = styled.svg` height: ${({ height }) => height}; ` const Path = styled.path` fill: ${({ color }) => color}; ` export default function Pattern({ height, color }) { return () } Pattern.propTypes = { height: PropTypes.string, color: PropTypes.string, } Pattern.defaultProps = { height: '10px', color: 'blue', }
I introduce the modal component and pass it.
Simplified components:
import React from 'react' import PropTypes from 'prop-types' import styled from 'styled-components' // Components import { Pattern } from '../atoms' const Container = styled.div` // Removed ` // HERE const Repeat = styled.div` margin-bottom: ${({ theme }) => theme.space.normal}; width: 100%; background-image: url(${({ background }) => background}); background-repeat: repeat-x; ` export default function SoQues(props) { return () } SoQues.propTypes = { // props } }/>
But for some reason it won't render.
What am I doing wrong and how do I introduce a component and set it to repeat the background image horizontally?
You can render the SVG as a static markup, encode it to Base64 and use it as a URL:
Real-time testing
Using your code, it might look something like the following (I didn't test it)