Components/Helpers

Components/Helpers

Methods

(static) composeWithTracker(reactiveMapper, options) → {function}

A higher order component to wrap a reactive function with Meteor's Tracker

Source:
Parameters:
Name Type Description
reactiveMapper function

data fetching function to bind to a tracker

options React.Component | Boolean | Object

can be a custom loader, false (to disable), or a full options object

Returns:

composed function

Type
function

(static) copyHOCs(sourceComponentName, targetComponent) → {function|React.Component}

Wrap a new component with the HOCs from a different component

Source:
Parameters:
Name Type Description
sourceComponentName String

The name of the component to get the HOCs from

targetComponent function | React.Component

Component to wrap

Returns:

A new component wrapped with the HOCs of the source component

Type
function | React.Component

(static) getComponent(name) → {function|React.Component}

Get a component registered with registerComponent(name, component, ...hocs).

Source:
Parameters:
Name Type Description
name String

The name of the component to get.

Returns:

A (wrapped) React component

Type
function | React.Component

(static) getHOCs(name) → {function|React.Component}

Get the raw UI component without any possible HOCs wrapping it.

Source:
Parameters:
Name Type Description
name String

The name of the component to get.

Returns:

Array of HOCs

Type
function | React.Component

(static) getRawComponent(name) → {function|React.Component}

Get the raw UI component without any possible HOCs wrapping it.

Source:
Parameters:
Name Type Description
name String

The name of the component to get.

Returns:

A React component

Type
function | React.Component

(static) loadRegisteredComponents() → {Object}

Populate the final Components object with the contents of the lookup table. This should only be called once on app startup.

Source:
Returns:

An object containing all of the registered components

Type
Object

(static) registerComponent(name, rawComponent, hocs) → {React.Component}

Source:
Example
// Register a component and container(s) with a name.
// The raw component can then be extended or replaced.

// Structure of a component in the list:

ComponentsTable.MyComponent = {
   name: 'MyComponent',
   hocs: [fn1, fn2],
   rawComponent: React.Component
}
Parameters:
Name Type Description
name String

The name of the component to register.

rawComponent React.Component

Interchangeable/extendable component.

hocs function | Array

The HOCs to wrap around the raw component.

Returns:

returns the final wrapped component

Type
React.Component

(static) registerHOC(name, hocs) → {undefined}

Register containers (HOC) with a name. If some containers already exist for the component, they will be extended.

Source:
Parameters:
Name Type Description
name String

The name of the component to register.

hocs function | Array

The HOCs to wrap around the raw component.

Returns:
Type
undefined

(static) replaceComponent(name, newComponent, hocs) → {function|React.Component}

Replace a Reaction component with a new component and optionally add one or more higher order components. This function keeps track of the previous HOCs and wraps the new HOCs around previous ones

Source:
Parameters:
Name Type Description
name String

The name of the component to register.

newComponent React.Component

Interchangeable/extendable component.

hocs function | Array

The HOCs to compose with the raw component.

Returns:

A component callable with Components[name]

Type
function | React.Component

(static) withAnimateHeight(component) → {function}

A wrapper that reactively injects an extended version of react-animate-height's into a component.

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with a "AnimateHeight" prop

Type
function

(static) withCSSTransition(component) → {Object}

A wrapper to dynamically import & inject react-transition-group's into a component

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with a "CSSTransition" prop

Type
Object

(static) withCurrentAccount(component) → {function}

A wrapper to reactively inject the current account into a component. This assumes you have signed up and are not an anonymous user.

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with a "currentAccount" prop

Type
function

(static) withCurrentUser(component) → {function}

A wrapper to reactively inject the current user into a component

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with a "currentUser" prop

Type
function

(static) withIsAdmin(component) → {function}

A wrapper to reactively inject the current user's admin status. Sets a boolean 'isAdmin' prop on the wrapped component.

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with an "isAdmin" prop

Type
function

(static) withIsOwner(component) → {function}

A wrapper to reactively inject the current user's owner status. Sets a boolean 'isOwner' prop on the wrapped component.

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with an "isOwner" prop

Type
function

(static) withMoment(component) → {function}

A wrapper to reactively inject the moment package into a component

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with a "moment" prop

Type
function

(static) withMomentTimezone(component) → {function}

A wrapper to reactively inject the moment package into a component

Source:
Parameters:
Name Type Description
component function | React.Component

the component to wrap

Returns:

the new wrapped component with a "moment" prop

Type
function

(static) withPermissions(roles, group) → {function}

A wrapper to reactively inject a user's permission based on group or roles Group access is given to users at that group level and above

Source:
Parameters:
Name Type Description
roles Array | String

String or array of strings of permissions to check. default: roles=["guest", "anonymous"]

group String

Slug title of a group to check against. Group option supercedes roles option. default: group="customer".

Returns:

the new wrapped component with a "hasPermissions" prop

Type
function