Permalink
78c8638 Mar 23, 2018
1 contributor

Users who have contributed to this file

37 lines (22 sloc) 670 Bytes

mock()

Create a mock React component whose implementation can be postponed.

Example

Create a mock and implement it

import {mock} from 'libreact/lib/mock';

const Player = mock();

// Now you can already use <Player>.
<Player />

// But implement it only later.
Player.implement(RealPlayer);

Specify placeholder for the mock

const MySvg = mock({
    loading: <span>SVG is loading...</span>
});

Reference

Receives configuration object, with the following keys:

  • loading - React element or component to show while the mock is not implemented.
  • .implement() - use this method to set the implementation of your mock component.