Skip to content

Commit

Permalink
helpful error message when defaultClass props forgotten
Browse files Browse the repository at this point in the history
  • Loading branch information
franklintarter committed Oct 15, 2019
1 parent 9c81b0a commit 8ba2eaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwindcss-overload",
"version": "0.0.2",
"version": "0.0.3",
"description": "tailwindcss-overload",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export const overloadTailwind = (initialClasses, overloadClasses) => {

export const withTailwindOverload = PassedComponent => {
return ({ className, ...rest }) => {
if (!PassedComponent.defaultClassName) {
throw new Error(
"No defaultClassName found. Components wrapped withTailwindOverload() require defaultClassName property 'MyComponent.defaultClassname = \"text-gray-500\"'"
);
}
const overloadedClasses = overloadTailwind(
PassedComponent.defaultClassName,
className
Expand Down

0 comments on commit 8ba2eaa

Please sign in to comment.