Tiqa / redux-polyglot

Polyglot.js bindings for Redux
MIT License
58 stars 13 forks source link

redux-polyglot 1.0.0 #79

Open guillaumearm opened 7 years ago

guillaumearm commented 7 years ago

due to #77 and other issues, I think it's time to plan to do some breaking changes.

My first idea is to change the actual translate component enhancer in order to support all react-redux features.

In addition, I think that using a function named `translate' to connect a component to a redux store is a bit confusing

I propose a mapStateToProps enhancer which can be named withPolyglot :

connect(
  withPolyglot('my_scope')(mapStateToProps),
  mapDispatchToProps,
  mergeProps,
  options,
)(Component);

// example without scope
withPolyglot()(mapStateToProps);

// example without mapStateToProps;
withPolyglot('myScope')()

// example without scope and mapStateToProps
withPolyglot()();

Edit:

The usual case will be something like that :

const mapStateToProps = withPolyglot()(state => ({
  a: getA(state),
  b: getB(state),
}))

export default connect(mapStateToProps)(Component);
guillaumearm commented 7 years ago

@satazor @JalilArfaoui @jvincent42 : your opinions are welcome