How to use the warning function in warning

To help you get started, we’ve selected a few warning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github salesforce / design-system-react / utilities / warning / future-property.js View on Github external
future = function(control, propValue, newProp, comment) {
		const additionalComment = comment ? ` ${comment}` : '';
		if (!hasWarned[control + newProp]) {
			/* eslint-disable max-len */
			warning(
				!propValue,
				`[Design System React] \`${newProp}\` of ${control} is not implemented yet. Please check future releases for \`${newProp}\`.${additionalComment}`
			);
			/* eslint-enable max-len */
			hasWarned[control + newProp] = !!propValue;
		}
	};
}
github Yoctol / bottender / packages / bottender-handlers / src / LineHandler.js View on Github external
if (args.length < 2) {
      const [handler]: [FunctionalHandler | Builder] = (args: any);

      this.on(context => context.event.isPayload, handler);
    } else {
      // eslint-disable-next-line prefer-const
      let [pattern, handler]: [
        Pattern,
        FunctionalHandler | Builder
      ] = (args: any);

      if (handler.build) {
        handler = handler.build();
      }

      warning(
        typeof pattern === 'function' ||
          typeof pattern === 'string' ||
          pattern instanceof RegExp,
        `'onPayload' only accepts string, regex or function, but received ${typeof pattern}`
      );

      if (typeof pattern === 'function') {
        const predicate: Predicate = pattern;
        this.on(
          context =>
            context.event.isPayload &&
            predicate(context.event.payload, context),
          handler
        );
      } else {
        if (pattern instanceof RegExp) {
github qiqiboy / react-formutil / lib / utils.js View on Github external
export var parsePath = function parsePath() {
    for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
        args[_key3] = arguments[_key3];
    }

    var target = args[0],
        path = args[1],
        value = args[2];


    warning(typeof path === 'string', 'The second parameter(' + JSON.stringify(path) + ') of parsePath() must be a string.');

    var pathSymbols = (path.match(PATH_REGEXP) || []).map(function (s) {
        return s.replace(/\s/g, '');
    });
    var pathWords = path.split(PATH_REGEXP).map(function (s) {
        return s.trim();
    }).filter(function (item) {
        return item !== '';
    });
    var scope = target;

    try {
        if (args.length < 3) {
            for (var index = 0, len = pathWords.length; index < len; index++) {
                var word = executeWord(pathWords[index]);
github carbon-design-system / carbon / src / components / removed-component.js View on Github external
const warn = () => {
    if (__DEV__) {
      warning(didWarnAboutRemoval, `The \`${name}\` component has been removed.`);
      didWarnAboutRemoval = true;
    }
  };
  return class {
github mui-org / material-ui / src / styles / withStyles.js View on Github external
...Object.keys(classesProp).reduce((accumulator, key) => {
            warning(
              renderedClasses[key] || this.disableStylesGeneration,
              [
                `Material-UI: the key \`${key}\` ` +
                  `provided to the classes property is not implemented in ${getDisplayName(
                    Component,
                  )}.`,
                `You can only override one of the following: ${Object.keys(renderedClasses).join(
                  ',',
                )}`,
              ].join('\n'),
            );

            warning(
              !classesProp[key] || typeof classesProp[key] === 'string',
              [
                `Material-UI: the key \`${key}\` ` +
github Bandwidth / shared-components / src / layouts / Form / FieldWrapper.js View on Github external
componentDidMount() {
    warning(true, 'DEPRECATED: the Field system is now deprecated. Please use Flow instead. (from FieldWrapper)');
  }
github sghall / react-compound-slider / src / Slider / Slider.js View on Github external
cloned.forEach(({ key, val }) => {
        const v0 = this.valueToStep(val)

        warning(
          v0 === val,
          `React Electric Slide: Invalid default value. Changing ${val} to ${v0}.`,
        )

        warning(
          !pushed[key],
          `React Electric Slide: No duplicate keys allowed. Skipping "${key}" key.`,
        )

        if (!pushed[key]) {
          pushed[key] = true
          values.push({ key, val: v0 })
        }
      })
github Yoctol / messaging-apis / packages / messaging-api-slack / src / SlackOAuthClient.ts View on Github external
postMessage(
    channel: string,
    inputMessage: Types.Message | string,
    options: Types.PostMessageOptionalOptions = {}
  ): Promise {
    warning(
      false,
      '`postMessage` is deprecated. Use `chat.postMessage` instead.'
    );

    const message =
      typeof inputMessage === 'string' ? { text: inputMessage } : inputMessage;

    return this._postMessage({
      channel,
      ...message,
      ...options,
    });
  }
github Yoctol / bottender / packages / bottender / src / line / LineContext.ts View on Github external
async linkRichMenu(richMenuId: string): Promise {
    if (this._session && this._session.user) {
      return this._client.linkRichMenu(this._session.user.id, richMenuId, {
        ...(this._customAccessToken
          ? { accessToken: this._customAccessToken }
          : undefined),
      } as any);
    }
    warning(
      false,
      'linkRichMenu: should not be called in context without session user'
    );
  }
github fi3ework / react-cloud-music / src / utils / LiveRoute.tsx View on Github external
UNSAFE_componentWillMount() {
    warning(
      !(this.props.component && this.props.render),
      'You should not use  and  in the same route;  will be ignored'
    )

    warning(
      !(this.props.component && this.props.children && !isEmptyChildren(this.props.children)),
      'You should not use  and  in the same route;  will be ignored'
    )

    warning(
      !(this.props.render && this.props.children && !isEmptyChildren(this.props.children)),
      'You should not use  and  in the same route;  will be ignored'
    )
  }

warning

A mirror of Facebook's Warning

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis