I like using the styled components naming convention where you do <S.SomeName>...</S.SomeName>, however I've encountered a problem where I need to import a component's styles and then some shared styled components as well but I can't import it as S again.
Here is my folder structure:
src
├── api
│ ├── verb-api.js
│ └── list-api.js
├── axios
│ └── index.js
├── components
│ └── ListsCard
│ ├── SubListsCard
│ │ ├── AnalyticsPage.js
│ │ ├── VerbsPage.js
│ │ ├── index.js
│ │ └── styles.js
│ ├── index.js
│ └── styles.js
├── hooks
│ ├── mutations
│ │ ├── useListMutation
│ │ └── useVerbMutation
│ ├── useClickOutside
│ └── useFocusInput
├── routes
│ ├── Home.js
│ ├── index.css
│ └── index.js
└── index.js
I need to use the styles from SubListsCard/styles.js and ListsCard/styles.js for my SubListsCard component. (I might make a folder called shared an import from that, instead of importing from ListsCard/styles.js).
My Solution was just import the shared styled components into the SubListsCard/styles.js and export it out:
import styled from "styled-components"
import {SomeComponent, OtherComponent} from "../styles"
export {SomeComponent, OtherComponent};
const Name = styled.div`
...
`;
is there any better way of doing this?
Thanks in advance :)
import { SomeComponent as foo }or similar? - F.P