Skip to content

v2.0.0

Compare
Choose a tag to compare
@mikaelbr mikaelbr released this 29 Oct 20:25
· 261 commits to master since this release

As of v2.0.0, Omniscient is dependent of React v0.12.0. This React version introduces some changes, and no longer allows components, but elements. With this some changes, not too big but breaks the previous API.

Statics as properties

The most notable change is that the statics are moved to be a part of the properties.
Statics still doesn't effect whether or not the component should update.

Before you could do:

OmniscientComponent('someKey', cursor, statics);

But now you have to do:

OmniscientComponent('someKey', { cursor: cursor, statics: statics });

As a result of this, you now always get passed props to your render function.

Before you could do:

var OmniscientComponent = component(function (cursor) {
  return React.DOM.text({}, cursor.deref());
});

Now you have to do:

var OmniscientComponent = component(function (props) {
  return React.DOM.text({}, props.cursor.deref());
});

This:

OmniscientComponent(cursor);

Is translated to:

OmniscientComponent({ cursor: cursor });

You could also name your cursor:

var OmniscientComponent = component(function (props) {
  return React.DOM.text({}, props.name.deref());
});

// Usage
OmniscientComponent({ name: cursor });

With JSX

Also, with the way React now requires elements instead of components, there have to be a change in how we use Omniscient with JSX.

Before you could do:

<OmniscientComponent cursor={someCursor} />

But now you have to do:

<OmniscientComponent.jsx cursor={someCursor} />

// or
OmniscientComponent = OmniscientComponent.jsx;
<OmniscientComponent.jsx cursor={someCursor} />

// or
var OmniscientComponent = require('someComponent').jsx;
<OmniscientComponent.jsx cursor={someCursor} />

Notice the .jsx after OmniscientComponent