How to use the fbjs/lib/warning function in fbjs

To help you get started, we’ve selected a few fbjs 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 Izzimach / react-three / src / mixins / THREEObject3DMixin.js View on Github external
applyTHREEObject3DPropsToObject: function(THREEObject3D, oldProps, props) {
    // if a matrix transformation is defined, it will handle position,
    // rotation, and scaling
    if (typeof props.matrix !== 'undefined') {
      THREEObject3D.matrix.copy(props.matrix);

      // prevent the matrix from being over-written on render
      // (see https://threejs.org/docs/manual/introduction/Matrix-transformations.html)
      THREEObject3D.matrixAutoUpdate = false;

      warning(typeof props.position === 'undefined', "The `position` property "+
              "of 3D objects is ignored when the `matrix` property is specified");
      warning(typeof props.rotation === 'undefined', "The `rotation` property "+
              "of 3D objects is ignored when the `matrix` property is specified");
      warning(typeof props.quaternion === 'undefined', "The `quaternion` property "+
              "of 3D objects is ignored when the `matrix` property is specified");
      warning(typeof props.scale === 'undefined', "The `scale` property "+
              "of 3D objects is ignored when the `matrix` property is specified");
    } else {
      if (typeof props.position !== 'undefined') {
        THREEObject3D.position.copy(props.position);
      } else {
        THREEObject3D.position.set(0,0,0);
      }

      // rotation be specified using either Euler angles or a quaternion
      if (typeof props.rotation !== 'undefined') {
github toxicFork / react-three-renderer / src / lib / descriptors / Material / TextureDescriptor.js View on Github external
addToSlotOfMaterial(material, slot, texture) {
    material.userData[`_has${slot}}TextureChild`] = true;

    if (material.userData[`_${slot}}Property`]) {
      let slotInfo = 'texture';

      if (slot !== 'map') {
        slotInfo += `with a '${slot}' slot`;
      }

      warning(false, 'The material already has a' +
        ` '${slot}' property but a ${slotInfo} is being added as a child.` +
        ' The child will override the property.');
    } else {
      // removing invariant to enable slot swapping
    }

    if (material[slot] !== texture) {
      material[slot] = texture;
    }
  }
github toxicFork / react-three-renderer / src / lib / React3Renderer.js View on Github external
const prevComponent = this.getTopLevelWrapperInContainer(container);
    if (!prevComponent) {
      // Check if the node being unmounted was rendered by React, but isn't a
      // root node.
      const containerHasNonRootReactChild = this.hasNonRootReactChild(container);

      // Check if the container itself is a React root node.
      const isContainerReactRoot = !!(
        container
        && container.userData
        && container.userData.markup
        && container.userData.markup[ID_PROPERTY_NAME]
      );

      if (process.env.NODE_ENV !== 'production') {
        warning(
          !containerHasNonRootReactChild,
          'unmountComponentAtNode(): The node you\'re attempting to unmount ' +
          'was rendered by React and is not a top-level container. %s',
          (
            isContainerReactRoot ?
              'You may have accidentally passed in a React root node instead ' +
              'of its container.' :
              'Instead, have the parent component update its state and ' +
              'rerender in order to remove this component.'
          )
        );
      }

      return false;
    }
github react-native-community / react-native-geolocation / js / index.js View on Github external
stopObserving: function() {
    if (updatesEnabled) {
      RNCGeolocation.stopObserving();
      updatesEnabled = false;
      for (let ii = 0; ii < subscriptions.length; ii++) {
        const sub = subscriptions[ii];
        if (sub) {
          warning(false, 'Called stopObserving with existing subscriptions.');
          sub[0].remove();
          // array element refinements not yet enabled in Flow
          const sub1 = sub[1];
          sub1 && sub1.remove();
        }
      }
      subscriptions = [];
    }
  },
};
github toxicFork / react-three-renderer / src / lib / descriptors / Light / LightDescriptorBase.js View on Github external
updateAllMaterials(threeObject) {
    const rootInstance = threeObject.userData.markup._rootInstance;
    if (rootInstance && !rootInstance._willUnmount) {
      if (process.env.NODE_ENV !== 'production') {
        if (!this._warnedAboutLightMaterialUpdate
          && !threeObject.userData._updatesRefreshAllMaterials) {
          const owner = threeObject.userData.react3internalComponent._currentElement._owner;

          const elementType = threeObject.userData.react3internalComponent._elementType;

          warning(this._warnedAboutLightMaterialUpdate,
            LightDescriptorBase.getDynamicWarningMessage(elementType, owner));
          this._warnedAboutLightMaterialUpdate = true;
        }
      }

      rootInstance.allMaterialsNeedUpdate();
    }
  }
}
github facebook / react / packages / react-dom / src / client / ReactDOMFiberInput.js View on Github external
'Input elements must be either controlled or uncontrolled ' +
          '(specify either the checked prop, or the defaultChecked prop, but not ' +
          'both). Decide between using a controlled or uncontrolled input ' +
          'element and remove one of these props. More info: ' +
          'https://fb.me/react-controlled-components',
        getCurrentFiberOwnerName() || 'A component',
        props.type,
      );
      didWarnCheckedDefaultChecked = true;
    }
    if (
      props.value !== undefined &&
      props.defaultValue !== undefined &&
      !didWarnValueDefaultValue
    ) {
      warning(
        false,
        '%s contains an input of type %s with both value and defaultValue props. ' +
          'Input elements must be either controlled or uncontrolled ' +
          '(specify either the value prop, or the defaultValue prop, but not ' +
          'both). Decide between using a controlled or uncontrolled input ' +
          'element and remove one of these props. More info: ' +
          'https://fb.me/react-controlled-components',
        getCurrentFiberOwnerName() || 'A component',
        props.type,
      );
      didWarnValueDefaultValue = true;
    }
  }

  const node = ((element: any): InputWithWrapperState);
  const defaultValue = props.defaultValue == null ? '' : props.defaultValue;
github rsocket / rsocket-js / packages / rsocket-flowable / src / Flowable.js View on Github external
onError(error: Error): void {
    if (this._started && !this._active) {
      warning(
        false,
        'Flowable: Invalid call to onError(): %s.',
        this._active
          ? 'onComplete/onError was already called'
          : 'onSubscribe has not been called',
      );
      return;
    }
    this._active = false;
    this._started = true;
    this._subscriber.onError && this._subscriber.onError(error);
  }
github some-react-components / react-scrollchor / src / animatescroll.js View on Github external
export default function animateScroll(id, animate) {
  const element = id ? document.getElementById(id) : document.body;

  warning(element, `Cannot find element: #${id}`);

  scrollTo(element, animate);
}
github facebook / react / packages / react-dom / src / client / ReactDOMFiberInput.js View on Github external
false,
        'A component is changing an uncontrolled input of type %s to be controlled. ' +
          'Input elements should not switch from uncontrolled to controlled (or vice versa). ' +
          'Decide between using a controlled or uncontrolled input ' +
          'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s',
        props.type,
        getCurrentFiberStackAddendum(),
      );
      didWarnUncontrolledToControlled = true;
    }
    if (
      node._wrapperState.controlled &&
      !controlled &&
      !didWarnControlledToUncontrolled
    ) {
      warning(
        false,
        'A component is changing a controlled input of type %s to be uncontrolled. ' +
          'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
          'Decide between using a controlled or uncontrolled input ' +
          'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s',
        props.type,
        getCurrentFiberStackAddendum(),
      );
      didWarnControlledToUncontrolled = true;
    }
  }

  updateChecked(element, props);

  const value = getSafeValue(props.value);