DEV Community

Discussion on: Styling in React

Collapse
 
seanmclem profile image
Seanmclem

Where do the props come from for the dynamic styled-component for props => props.primary?

Collapse
 
dastasoft profile image
dastasoft

Like any other React component, under the hood styled-component is creating a valid React component which you will use in JSX.

If you use my approach to divide the styled and the logic in two different files (with MyComponent.js and MyComponentBase.js) all props go through both JS and you can decide where to use them.

Collapse
 
seanmclem profile image
Seanmclem

But you don't have to pass them in to a function manually? They're just automatically available on the styled.div template string as a "props" object?

Thread Thread
 
dastasoft profile image
dastasoft

That's correct, they're available on the styled.div because you pass the props when you use the component in the JSX, check the example provided in the official webpage: styled-components.com/

Thread Thread
 
seanmclem profile image
Seanmclem

Thanks, I see now. They're the actual props passed to the styled component. Since the library creates components and not just styles