How to use the react-cosmos-utils/lib/unserializable-parts function in react-cosmos-utils

To help you get started, we’ve selected a few react-cosmos-utils 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 react-cosmos / react-cosmos / packages / react-component-playground / src / components / component-playground.jsx View on Github external
fixtureUnserializableProps: {},
        fixtureUserInput: '{}',
        isFixtureUserInputValid: true,
      };

      if (this.isFixtureSelected(props) && this.doesSelectedFixtureExist(props)) {
        const originalFixtureContents = this.getSelectedFixtureContents(props);

        // Unserializable props are stored separately from serializable ones
        // because the serializable props can be overriden by the user using
        // the editor, while the unserializable props are always attached
        // behind the scenes
        const {
          unserializable,
          serializable,
        } = splitUnserializableParts(originalFixtureContents);

        _.assign(state, {
          fixtureContents: serializable,
          fixtureUnserializableProps: unserializable,
          fixtureUserInput: this.getStringifiedFixtureContents(serializable),
        });
      }

      return state;
    },
  },
github react-cosmos / react-cosmos / packages / react-cosmos / src / components / Loader.jsx View on Github external
if (!hasInitialFixture({ component, fixture })) {
    // Nothing is rendered until parent frame says so
    return {
      component: null,
      fixture: {
        unserializable: {},
        serializable: {},
      },
      fixtureUpdateId: 0,
    };
  }

  const {
    unserializable,
    serializable,
  } = splitUnserializableParts(fixtures[component][fixture]);

  return {
    component,
    fixture: {
      unserializable,
      serializable: fixtureBody || serializable,
    },
    // Used as React Element key to ensure loaded components are rebuilt on
    // every fixture change (instead of reusing instance and going down the
    // componentWillReceiveProps route)
    fixtureUpdateId: getUpdateId(),
  };
};

react-cosmos-utils

Libs shared between React Cosmos modules

MIT
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis

Similar packages