Module: xblocks-core/view

Methods

(static) create(component) → {function}

Create class view node.

Parameters:
Name Type Description
component Object | array

settings view creation

Source:
See:
Returns:
Type
function
Example
import view from 'xblocks-core/view';

var XBButtonContent = view.create({
    displayName: 'XBButtonContent',
    render: function () {
        return (
            <span {...this.props}>{this.props.children}</span>
        );
    }
});

view.register('xb-button', {
    displayName: 'xb-button',
    render: function () {
        return (
            <button>
                <XBButtonContent {...this.props} />
            </button>
        );
    }
});

(static) getClass(blockName) → {function}

Get class view node.

Parameters:
Name Type Description
blockName string

the name of the new node

Source:
Returns:
Type
function

(static) getFactory(blockName) → {function}

Get factory view node.

Parameters:
Name Type Description
blockName string

the name of the new node

Source:
Returns:
Type
function

(static) register(blockName, component) → {function}

Registration of a new node.

Parameters:
Name Type Description
blockName string

the name of the new node

component Object | array | React.Component

settings view creation

Source:
See:
Throws:

Specified item "$" is already defined

Type
blockName
Returns:
Type
function
Example
import view from 'xblocks-core/view';
view.register('xb-button', {
    displayName: 'xb-button',
    render: function () {
        return (
            <button {...this.props}>{this.props.children}</button>
        );
    }
});