This package has been deprecated

Author message:

No longer supported.

@react-lifecycle-emulator/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

React-Lifecycle-Emulator Core

A package to emulate React's lifecycle for components while making it easy to unit test. For more information, see the full react-lifecycle-emulator project.

Core usage

TypeScript:

import {reactEmulator} from 'react-lifecycle-emulator';

// without TSX
const emulator = reactEmulator<MyComponent>(MyComponent);
const target = emulator.construct(initialProps, context);

// with TSX
const target = emulate<MyComponent>(<MyComponent />);

// control lifecycle
target.controls.mount();
target.controls.updateProps(newProps);
target.controls.updateProps(newProps, newContext);

// access functions on component instance
target.component.handleClick();

// access the rendered JSX elements
const rendered: JSX.Element | null = target.getRendered();

JavaScript:

import {emulate} from 'react-lifecycle-emulator';

const target = emulate(<MyComponent {...initialProps} />, context);

// control lifecycle
target.controls.mount();
target.controls.updateProps(newProps);
target.controls.updateProps(newProps, newContext);

// access functions on component instance
target.component.handleClick();

// access the rendered JSX elements
const rendered = target.getRendered();

Note that the core framework never mounts children, this way you can test the behavior of your component in isolation.

/@react-lifecycle-emulator/core/

    Package Sidebar

    Install

    npm i @react-lifecycle-emulator/core

    Weekly Downloads

    5

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • mdekrey