How to use the carbon-components/es/globals/js/settings.prefix function in carbon-components

To help you get started, we’ve selected a few carbon-components 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 carbon-design-system / carbon-website-archive / src / components / ComponentExample / ComponentExample.js View on Github external
_releaseAndInstantiateComponents() {
    const handles = this._handles;
    for (let instance = handles.pop(); instance; instance = handles.pop()) {
      instance.release();
    }
    const ref = this._ref;
    if (ref) {
      const { component } = this.props;
      const currentComponent = component
        .replace(/-([a-z])/g, (match, token) => token.toUpperCase())
        .replace(/^([a-z])/, (match, token) => token.toUpperCase());
      // TODO: See if instances with different prefixes may exist as the same time.
      // If so, we need to figure out more sophisticted approach here.
      settings.prefix = 'bx';
      (componentNamesMap[currentComponent] || [currentComponent]).forEach(
        name => {
          const TheComponent = components[name];
          if (TheComponent) {
            const options = {};
            if (name === 'DatePicker') {
              // Same as `this._liveContainerRef.current`, but that may not have been set up yet
              const liveContainerRef = ref.closest('.component-example__live');
              options.appendTo = liveContainerRef;
              options.onPreCalendarPosition = (
                selectedDates,
                value,
                { _positionElement, calendarContainer }
              ) => {
                // Make it "post" positioning handler
                Promise.resolve().then(() => {