How to use react-component-tree - 10 common examples

To help you get started, we’ve selected a few react-component-tree 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 skidding / react-component-playground / tests / components / component-playground / events.js View on Github external
function render(extraParams) {
    // Alow tests to extend fixture before rendering
    _.merge(params, extraParams);

    component = ComponentTree.render({
      component: ComponentPlayground,
      snapshot: params,
      container: document.createElement('div')
    });
  };
github skidding / react-component-playground / tests / components / component-playground / state.js View on Github external
function render(extraProps) {
    // Alow tests to extend fixture before rendering
    _.merge(params, extraProps);

    component = ComponentTree.render({
      component: ComponentPlayground,
      snapshot: params,
      container: document.createElement('div')
    });
  };
github skidding / react-component-playground / tests / components / component-playground / children.js View on Github external
function render(extraParams) {
    // Alow tests to extend fixture before rendering
    _.merge(params, extraParams);

    component = ComponentTree.render({
      component: ComponentPlayground,
      snapshot: params,
      container: document.createElement('div')
    });

    if (params.component) {
      childParams = component.children.preview.call(component);
    }
  }
github skidding / react-component-playground / tests / components / component-playground / render.js View on Github external
function render(extraProps) {
    // Alow tests to extend fixture before rendering
    _.merge(params, extraProps);

    component = ComponentTree.render({
      component: ComponentPlayground,
      snapshot: params,
      container: document.createElement('div')
    });
    $component = $(component.getDOMNode());
  }
github skidding / react-component-playground / tests / components / component-playground / events.js View on Github external
beforeEach(function() {
    sinon.stub(console, 'error');

    // Don't render any children
    sinon.stub(ComponentTree.loadChild, 'loadChild');

    params = {
      components: {},
      router: {
        routeLink: sinon.spy()
      }
    };
  });
github skidding / react-component-playground / tests / components / component-playground / children.js View on Github external
beforeEach(function() {
    // Don't render any children
    sinon.stub(ComponentTree.loadChild, 'loadChild');

    params = {
      components: {
        FirstComponent: {
          class: 'FirstComponent',
          fixtures: {
            'default state': {}
          }
        }
      },
      router: {
        routeLink: sinon.spy()
      }
    };
  });
github skidding / react-component-playground / tests / components / component-playground / render.js View on Github external
beforeEach(function() {
    // Don't render any children
    sinon.stub(ComponentTree.loadChild, 'loadChild');

    params = {
      components: {
        FirstComponent: {
          fixtures: {
            'blank state': {},
            'error state': {},
            'simple state': {}
          }
        },
        SecondComponent: {
          fixtures: {
            'simple state': {}
          }
        }
      },
github NiGhTTraX / react-test-buffet / tests / helpers.js View on Github external
try {
    component = React.render(React.createElement(
        Component, props, fixture.children),
        _container);
  } catch (e) {
    throw new Error(
      `The component threw an exception while rendering:\n ${e.message}`);
  }

  if (fixture.state) {
    // Injecting state will trigger a new render cycle and we only care about
    // the calls caused by the last render
    sandbox.reset();

    ComponentTree.injectState(component, fixture.state);
  }

  return component;
}
github Tettra / react-visual-diff / example / src / App.js View on Github external
import ExampleComponent from 'react-deep-diff'

const last = array => array[array.length - 1]
const first = array => array[0]
const second = array => array[1]
const beforeLast = array => array[array.length - 2]

const el1 = <div>
  Hello
  <span>Wor<span>What up</span></span>
</div>


console.log('wat', serialize(el1))

const serialized = serialize(el1)

// console.log('json react', JSON.stringify(el1))
// 
// const el2 = <div>
//   Hello
//   <span>World<span>how do you do</span></span>
//   <div>
//     <h1>This is a new Element</h1>
//   </div>
// </div>
// 
// // path be like ["props", "children", 1, "props", "children", 1, "props", "children"]
// const changeReactElement = (element, path, change, renderChange) =&gt; {
//   // first path has to always be props, if not return element
//   console.log('path', path)
//   if (path[0] !== 'props') {
github Tettra / react-visual-diff / example / src / App.js View on Github external
import takeWhile from 'lodash/takeWhile'
import { serialize, render } from 'react-component-tree'
import ExampleComponent from 'react-deep-diff'

const last = array =&gt; array[array.length - 1]
const first = array =&gt; array[0]
const second = array =&gt; array[1]
const beforeLast = array =&gt; array[array.length - 2]

const el1 = <div>
  Hello
  <span>Wor<span>What up</span></span>
</div>


console.log('wat', serialize(el1))

const serialized = serialize(el1)

// console.log('json react', JSON.stringify(el1))
// 
// const el2 = <div>
//   Hello
//   <span>World<span>how do you do</span></span>
//   <div>
//     <h1>This is a new Element</h1>
//   </div>
// </div>
// 
// // path be like ["props", "children", 1, "props", "children", 1, "props", "children"]
// const changeReactElement = (element, path, change, renderChange) =&gt; {
//   // first path has to always be props, if not return element

react-component-tree

Serialize and reproduce the state of an entire tree of React components

MIT
Latest version published 7 years ago

Package Health Score

73 / 100
Full package analysis

Similar packages