Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(refreshcache): minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marielaures committed Nov 20, 2017
1 parent 72d865c commit 1f6cdaa
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/react-instantsearch/src/core/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ InstantSearch.propTypes = {

createURL: PropTypes.func,

refresh: PropTypes.bool,
refresh: PropTypes.bool.isRequired,

searchState: PropTypes.object,
onSearchStateChange: PropTypes.func,
Expand Down
5 changes: 3 additions & 2 deletions packages/react-instantsearch/src/core/InstantSearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const DEFAULT_PROPS = {
root: {
Root: 'div',
},
refresh: false,
};

describe('InstantSearch', () => {
Expand Down Expand Up @@ -265,7 +266,7 @@ describe('InstantSearch', () => {

createInstantSearchManager.mockImplementation(() => ism);

const wrapper = mount(
const wrapper = shallow(
<InstantSearch {...DEFAULT_PROPS}>
<div />
</InstantSearch>
Expand Down Expand Up @@ -295,7 +296,7 @@ describe('InstantSearch', () => {

createInstantSearchManager.mockImplementation(() => ism);

const wrapper = mount(
const wrapper = shallow(
<InstantSearch {...DEFAULT_PROPS}>
<div />
</InstantSearch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function createInstantSearch(defaultAlgoliaClient, root) {
searchParameters: PropTypes.object,
createURL: PropTypes.func,
searchState: PropTypes.object,
refresh: PropTypes.bool,
refresh: PropTypes.bool.isRequired,
onSearchStateChange: PropTypes.func,
onSearchParameters: PropTypes.func,
resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
Expand Down
52 changes: 27 additions & 25 deletions stories/RefreshCache.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,20 @@ import { InstantSearch, SearchBox } from '../packages/react-instantsearch/dom';
import { CustomHits } from './util';

const stories = storiesOf('RefreshCache', module);
const buttonStyle = {
borderRadius: '4px',
padding: '10px',
border: 'none',
fontSize: '12px',
cursor: 'pointer',
color: '#fff',
background: '#3369e7',
};

const divStyle = {
borderRadius: '2px',
padding: '10px',
marginTop: '15px',
border: 'none',
fontSize: '12px',
color: '#999999',
background: '#F3F3F3',
display: 'block',
};

class AppWithRefresh extends Component {
constructor(props) {
super(props);
this.state = {
refresh: false,
};
this.refresh = this.refresh.bind(this);
}

refresh() {
refresh = () => {
this.setState(prevState => ({
refresh: !prevState.refresh,
}));
}
};

onSearchStateChange = () => {
this.setState({ refresh: false });
Expand Down Expand Up @@ -112,10 +91,33 @@ class AppWithRefresh extends Component {
placeholder: 'Search our furnitures: chairs, tables etc.',
}}
/>
<button onClick={this.refresh} style={buttonStyle}>
<button
onClick={this.refresh}
style={{
borderRadius: '4px',
padding: '10px',
border: 'none',
fontSize: '12px',
cursor: 'pointer',
color: '#fff',
background: '#3369e7',
}}
>
Refresh cache
</button>
<button style={divStyle} disabled>
<button
style={{
borderRadius: '2px',
padding: '10px',
marginTop: '15px',
border: 'none',
fontSize: '12px',
color: '#999999',
background: '#F3F3F3',
display: 'block',
}}
disabled
>
Refresh is set to: <em>{displayRefresh}</em>
</button>

Expand Down

0 comments on commit 1f6cdaa

Please sign in to comment.