Bit component Library is a cloud based website, which enables users to share components across multiple teams and projects.
A component can be made reusable via props
. There are a number of ways of making a component reusable and this depends on which aspects of the component should be made resuable.
Here is a basic example of a reusable component.
const ReusableComponent = (props) => {
return (
<>
<p>name: {props.name}</p>
<p>greeting: {props.greeting}</p>
</>
)
}
...
<ReusableComponent
name={'example'}
greet={'hello}
/>
Less code in application
Reuse logic for components in multiple places
More efficent
Having to add lots of conditions to component when using the component in different places, which require different parts of the component
Sometimes increases complexity across project
Install Bit globally via NPM
npm install bit-bin --global
cd <project-diary>
bit init
bit login
big add src/components
bit status
bit import bit.envs/compilers/react --complier
bit tag --all 1.0.0
bit export <username>.<collection-name>
Bit gives an overview of the code, dependencies, and any console outputs.
Select the component to be used and in the right hand corner it will give the option to add the component via npm, yarn or bit.
The component can then be imported into a React project as: import componentName from '@bit/<user>.<component-name>'
🎉🌻