Skip to content

v3.0.0

Compare
Choose a tag to compare
@mikaelbr mikaelbr released this 18 Feb 21:08
· 193 commits to master since this release

Note: This release is missing dist-files. Use v3.0.1 for updated dist-files. Release should work just fine through Browserify/Webpack.

Addition

  • shouldComponentUpdate is now accessible on its own. This means that you
    can include the mixin into your code base without including unused code from
    the Omniscient core. #33
var shouldupdate = require('omniscient/shouldupdate');

var mixins = [{ shouldComponentUpdate: shouldupdate }];
var MyComponent = React.createClass({
  mixins: mixins,

  render: function () { /* ...* / }
});
  • Following 2. from Changes (changes to use lodash.isEqual), cursors can now be anywhere in the props three. See #39
React.render(MyComponent({ some: { path: { to: cursor }}}), document.body);
  • You can now have immutable structures as a part of your props/state #55
React.render(MyComponent({ obj: Immutable.List.of(1, 2, 3) }), document.body);
  • You can now pass on cursors directly to non-JSX components #43
var MyComponent = component(function (cursor) {
  // do something with cursor
});

React.render(MyComponent(myCursor), document.body);
  • You can now pass on immutable structure as single argument (as with cursor) #58
React.render(MyComponent(Immutable.List.of(1, 2, 3)), document.body);
  • You can now define component name through named render function 22bdf88
var Component = component(function DisplayName() {
  return <div>Hello!</div>;
});

in addition to previous syntax:

var Component = component('DisplayName', function () {
  return <div>Hello!</div>;
});
  • You can now set to always use JSX component (see Breaking Changes) 53e5318
var component = require('omniscient');

var localComponent = component.withDefaults({
  jsx: true
});

var Component = localComponent(function MyJsxComponent() {
  /* ... */
});

// Component is JSX component. No need for Component.jsx
React.render(<Component />, document.body);
  • You can now pass on statics as argument to non-JSX a523e59
var MyComponent = component(function (cursor, statics) {
  // do something with statics
});

React.render(MyComponent(myCursor, myStatic), document.body);

Breaking Changes

  • Can't longer override helper functions directly. Now you can create local component factories
    which doesn't alter global state. #36

Overview of all overridables:

var component = require('omniscient');

var localComponent = component.withDefaults({
  // Goes directly to component
  shouldComponentUpdate: function(nextProps, nextState), // check update
  jsx: false, // whether or not to default to jsx components

  // Is passed on to `shouldComponentUpdate`
  isCursor: function(cursor), // check if is props
  isEqualCursor: function (oneCursor, otherCursor), // check cursor
  isEqualState: function (currentState, nextState), // check state
  isImmutable: function (currentState, nextState), // check if object is immutable
  isEqualProps: function (currentProps, nextProps), // check props
  unCursor: function (cursor) // convert from cursor to object
});

You can also override directly on shouldComponentUpdate

var shouldUpdate = require('omniscient/shouldUpdate');

var localShouldUpdate = shouldUpdate.withDefaults({
  isCursor: function(cursor), // check if is props
  isEqualCursor: function (oneCursor, otherCursor), // check cursor
  isEqualState: function (currentState, nextState), // check state
  isImmutable: function (currentState, nextState), // check if object is immutable
  isEqualProps: function (currentProps, nextProps), // check props
  unCursor: function (cursor) // convert from cursor to object
});