Tiqa / redux-polyglot

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

fix: do not inject dispatch prop when using the enhancer #91

Closed satazor closed 6 years ago

satazor commented 6 years ago

The reason is that we might use the enhancer to translate stuff inside a component that also uses ...restProps to passdown props to a DOM element. Previously we had to declare the dispatch prop in the component just omit it:

const SomeComponent = ({ p, dispatch, ...restProps }) => <div { ...restProps }>{ p.t('foo') }</div>;

SomeComponent.propTypes = {
   p: PropTypes.object.isRequired,
   dispatch: PropTypes.func.isRequired,
};

export default translate(SomeComponent);

With this change, it's no longer necessary to do that:

const SomeComponent = ({ p, ...restProps }) => <div { ...restProps }>{ p.t('foo') }</div>;

SomeComponent.propTypes = {
   p: PropTypes.object.isRequired,
};

export default translate(SomeComponent);

Unrelated to this PR: prop-types dependency was missing

satazor commented 6 years ago

@guillaumearm Do you have some time to take a look at this?

guillaumearm commented 6 years ago

redux-polyglot@0.6.4 is out 🎉