How to use the invariant.default function in invariant

To help you get started, we’ve selected a few invariant 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 tomchentw / react-google-maps / src / lib / creators / OverlayViewCreator.js View on Github external
overlayView._mountContainerToPane = function _mountContainerToPane() {
      const mapPaneName = this.get(`mapPaneName`);
      invariant(
        !!mapPaneName,
`OverlayView requires a mapPaneName/defaultMapPaneName in your props instead of %s`,
        mapPaneName
      );

      this.getPanes()[mapPaneName].appendChild(this._containerElement);
    };
github tomchentw / react-google-maps / src / lib / creators / OverlayViewCreator.js View on Github external
overlayView._getPixelPosition = function _getPixelPosition() {
      const projection = this.getProjection();
      let position = this.get(`position`);
      invariant(
        !!position,
`OverlayView requires a position/defaultPosition in your props instead of %s`,
        position
      );
      if (projection && position) {
        if (!(position instanceof google.maps.LatLng)) {
          position = new google.maps.LatLng(position.lat, position.lng);
        }
        return projection.fromLatLngToDivPixel(position);
      }
    };
github tomchentw / react-google-maps / src / lib / utils / index.js View on Github external
export function triggerEvent(component, ...args) {
  const instance = __getInstance(component);
  invariant(instance,
`The react-google-maps component %s is not mounted, hence we can't find an
 associated Google Maps JavaScript API v3 instance with it.`, component);

  return google.maps.event.trigger(instance, ...args);
}
github tomchentw / react-google-maps / src / lib / creators / OverlayViewCreator.js View on Github external
overlayView._getPixelBounds = function _getPixelBounds() {
      const projection = this.getProjection();
      let bounds = this.get(`bounds`);
      invariant(!!bounds, `OverlayView requires a bounds in your props instead of %s`, bounds);
      if (projection && bounds) {
        if (!(bounds instanceof google.maps.LatLngBounds)) {
          bounds = new google.maps.LatLngBounds(
            new google.maps.LatLng(bounds.ne.lat, bounds.ne.lng),
            new google.maps.LatLng(bounds.sw.lat, bounds.sw.lng)
          );
        }
        return {
          sw: projection.fromLatLngToDivPixel(this.bounds.getSouthWest()),
          ne: projection.fromLatLngToDivPixel(this.bounds.getNorthEast()),
        };
      }
    };

invariant

invariant

MIT
Latest version published 7 years ago

Package Health Score

74 / 100
Full package analysis