diff --git a/generators/app/templates/src/components/SOQuestionsList/SOQuestionsList.js b/generators/app/templates/src/components/SOQuestionsList/SOQuestionsList.js index 6d6c60c..c6861aa 100644 --- a/generators/app/templates/src/components/SOQuestionsList/SOQuestionsList.js +++ b/generators/app/templates/src/components/SOQuestionsList/SOQuestionsList.js @@ -21,12 +21,12 @@ class SOQuestionsList extends React.Component { { questions.map((ques, i) => ( highlightable ? -
- +
+
: -
- +
+
)) } diff --git a/generators/app/templates/src/components/SOSearch/SOSearch.js b/generators/app/templates/src/components/SOSearch/SOSearch.js index 9cac26b..a212ebb 100644 --- a/generators/app/templates/src/components/SOSearch/SOSearch.js +++ b/generators/app/templates/src/components/SOSearch/SOSearch.js @@ -1,8 +1,9 @@ import React from 'react'; import { connect } from 'react-redux'; +import { Link } from 'react-router'; import { push } from 'react-router-redux'; -import { isLoaded as isLoadedSearch, load as loadResults } from './Actions'; +import { load as loadResults } from './Actions'; import SOQuestionsList from '../SOQuestionsList/SOQuestionsList'; import SOHot from '../SOHot/SOHot'; @@ -10,20 +11,22 @@ class SOSearch extends React.Component { static propTypes = { query: React.PropTypes.string.isRequired, questions: React.PropTypes.array.isRequired, - dispatch: React.PropTypes.func.isRequired + dispatch: React.PropTypes.func.isRequired, + loaded: React.PropTypes.bool.isRequired }; componentWillMount() { - const { dispatch, query } = this.props; - if (query !== '' && !isLoadedSearch(this.props)) { + const { dispatch, query, loaded } = this.props; + if (query !== '' && !loaded) { // Remember to make it into an object dispatch(loadResults({ query: query })); } } + // IMPORTANT: Used when we show the same component with different props componentWillUpdate(next) { if (next.query !== '' && (next.query !== this.props.query)) { - this.props.dispatch(loadResults({ query: next.params.query })); + next.dispatch(loadResults({ query: next.query })); } } @@ -33,11 +36,16 @@ class SOSearch extends React.Component {

Search StackOverflow

+

+ Example Searches: + Hello + World + React +

{ e.preventDefault(); dispatch(push('/sosearch/' + e.target.value)); - dispatch(loadResults({ query: e.target.value })); } } value={query} /> @@ -54,7 +62,7 @@ const mapStateToProps = (state, ownProps) => ( { query: ownProps.params ? ownProps.params.query : state.sosearch.data.query, questions: state.sosearch.data.results, - loading: state.sosearch.loading + loaded: state.sosearch.loaded } );