Reakit: Request: Whitelabeled warning messages from reakit-utils/warning

Created on 1 Nov 2019  路  4Comments  路  Source: reakit/reakit

(As always with my reakit-system-related requests, please feel free to say I should handle this myself for now.)

馃殌 Feature request

I would like warning in reakit-utils to support arbitrary labels and not have reakit hardcoded in the label.

Motivation

For my component library built with reakit and reakit-system, I'd like the ability to throw warnings in development and have them tagged with the name of my library, not reakit, so that I can control where to tell my engineers to look for internal documentation.

Example

When building custom components using reakit-system, I'd like to use the same useCreateElement / warning() pattern to flag issues in development.

For example, if an engineer passes an invalid icon token to my custom <Icon icon="..." /> component, I would like the warning to use the name of my library (since Reakit does not ship with an Icon component).

Possible implementations

  • Avoid hardcoding reakit in the finalLabel, and require callers of warning to include the full label by default.
  • Add a new argument to warning, something like tag or namespace, and default it to 'reakit'. Use that new argument instead of the hardcoded reakit.

If one of these implementations is suitable to you, or if there's another you suggest, I'm happy to build it out.

backer discussion feature utils

Most helpful comment

If we're going to make this more generic (which I'm totally open for), I'd go for an API like this:

warning(
  !error,
  "[reakit/A]",
  "Line 1.",
  "Line 2.",
  "",
  "Line 4"
);

So, in this case, there's no concept of label in the implementation.

All 4 comments

Hey @folz :wave:,

Thank you so much for supporting us on Open Collective :heart:.
We'll give a special attention to this issue.

If we're going to make this more generic (which I'm totally open for), I'd go for an API like this:

warning(
  !error,
  "[reakit/A]",
  "Line 1.",
  "Line 2.",
  "",
  "Line 4"
);

So, in this case, there's no concept of label in the implementation.

Also, make sure you're using it together with babel-plugin-dev-expression. Otherwise, your production bundle will end up with a bunch of strings that can't be minified.

Sounds good to me. I'll whip up a PR removing the concept of label and converting the existing callsites to include [reakit/*]. Should have it over soon.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

romainquellec picture romainquellec  路  5Comments

EmilEriksen picture EmilEriksen  路  4Comments

Slapbox picture Slapbox  路  5Comments

codyaverett picture codyaverett  路  4Comments

codyaverett picture codyaverett  路  6Comments