Nice! I think this is a great utility to build our own components without spending time creating our CSS as the project demands. It's good to have options.
BTW, In the last code snnipet you imported the components in this way:
import { PrimaryButton } from '../components/FormElements/Button'; import Input from '../components/FormElements/Input';
I would recommend to export them all using an index.js file in favor of a cleaner way to import them.
index.js
// Supose we have this modules - components |- form-elements |- primary-button |- input |- index.js |- index.js - pages
// components/form-items/index.js export * from "primary-button"; export { default as Input } from "input";
// components/index.js export * as FormItems from "form-items";
So you can import them in one of these ways
import FormItems from "../components"; return ( <div> <FormItems.Input /> <FormItems.PrimaryButton /> <div> ); // or import { PrimaryButton, Input } from "../components/form-items"; return ( <div> <Input /> <PrimaryButton /> <div> );
Thanks Jose. That's a good catch. I sometimes avoid creating index.js for small projects. But surely, that makes code more cleaner.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice! I think this is a great utility to build our own components without spending time creating our CSS as the project demands. It's good to have options.
BTW, In the last code snnipet you imported the components in this way:
I would recommend to export them all using an
index.js
file in favor of a cleaner way to import them.So you can import them in one of these ways
Thanks Jose. That's a good catch. I sometimes avoid creating index.js for small projects. But surely, that makes code more cleaner.