Skip to content

Commit

Permalink
fix(InfiniteHits): provide translation key for Load More (#2048)
Browse files Browse the repository at this point in the history
see: #2047
  • Loading branch information
Maxime Janton authored and vvo committed Mar 16, 2017
1 parent d1e90f3 commit 6130bf2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/react-instantsearch/src/components/InfiniteHits.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import React, {PropTypes, Component} from 'react';

import classNames from './classNames.js';
import translatable from '../core/translatable';

const cx = classNames('InfiniteHits');

class InfiniteHits extends Component {
render() {
const {hitComponent: ItemComponent, hits, hasMore, refine} = this.props;
const {hitComponent: ItemComponent, hits, hasMore, refine, translate} = this.props;
const renderedHits = hits.map(hit =>
<ItemComponent key={hit.objectID} hit={hit} />
);
const loadMoreButton = hasMore ?
<button {...cx('loadMore')} onClick={() => refine()}>Load more</button> :
<button {...cx('loadMore')} disabled>Load more</button>;
<button {...cx('loadMore')} onClick={() => refine()}>
{translate('loadMore')}
</button> :
<button {...cx('loadMore')} disabled>
{translate('loadMore')}
</button>;

return (
<div {...cx('root')}>
Expand All @@ -30,6 +36,7 @@ InfiniteHits.propTypes = {
]).isRequired,
hasMore: PropTypes.bool.isRequired,
refine: PropTypes.func.isRequired,
translate: PropTypes.func.isRequired,
};

InfiniteHits.defaultProps = {
Expand All @@ -43,4 +50,6 @@ InfiniteHits.defaultProps = {
>{JSON.stringify(hit).slice(0, 100)}...</div>,
};

export default InfiniteHits;
export default translatable({
loadMore: 'Load more',
})(InfiniteHits);
1 change: 1 addition & 0 deletions packages/react-instantsearch/src/widgets/InfiniteHits.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import InfiniteHitsComponent from '../components/InfiniteHits.js';
* the results. If it is not provided the rendering defaults to displaying the
* hit in its JSON form. The component will be called with a `hit` prop.
* @themeKey root - the root of the component
* @translationKey loadMore - the label of load more button
* @example
* import React from 'react';
Expand Down

0 comments on commit 6130bf2

Please sign in to comment.