flux icon indicating copy to clipboard operation
flux copied to clipboard

Return a "snapshot" of the store object instead of returning a reference to the object directly

Open gsklee opened this issue 11 years ago • 1 comments

Please consider updating the docs and examples from this pattern:

var user = {
      name: ''
    };

export default new class Store extends EventEmitter {

  ...

  get value() {
    return user;
  }

  ...

}();

to this pattern:

  get value() {
    return Object.assign({}, user);
  }

More information here.

gsklee avatar Mar 07 '15 06:03 gsklee

Use immutable data if you are working with shouldComponentUpdate. I'd recommend ImmutableJS for that.

We are keeping these examples very simple so they are easy to understand -- the minimum code required to explain the pattern. Use of shouldComponentUpdate fall outside of that.

fisherwebdev avatar Mar 07 '15 07:03 fisherwebdev