I'm developing a common npm package with React's components for later usages in several projects. I've got default snackbar components and one wrapper component that will return a certain snackbar depending on snackbar's type provided to the wrapper's props. Here is my snackbar wrapper's code:
const TYPES = {
[SNACKBAR_TYPES.SUCCESS]: SnackbarSuccess,
[SNACKBAR_TYPES.ERROR]: SnackbarError,
[SNACKBAR_TYPES.INFO]: SnackbarInfo,
[SNACKBAR_TYPES.LOADING]: SnackbarLoading
}
const CustomSnackbars = props => {
const CustomSnackbar = TYPES[props.snackbarType]
if (!CustomSnackbar) {
console.log('Invalid snackbar type was provided')
return null
}
return (
<CustomSnackbar {...props} />
)
}
This wrapper will be used in projects for creating CustomSnackbars container. But here comes one problem that every project will probably define it's own snackbars with it's own snackbar type. And I don't want to put every snackbar that I will have later in my projects to my common module. Is it possible to somehow extend CustomSnackbars wrapper from the each projects's side, so this wrapper will have specific to each project's snackbar types in addition to default snackbar types?