单击搜索按钮后导航栏消失了

时间:2018-09-28 07:34:09

标签: reactjs redux react-redux

我有一个搜索页面,其中包含一个输入,一个按钮,并且在匹配搜索时将呈现产品。单击搜索按钮后,我的导航栏消失了,但是就我所检查的而言,其他功能仍然运行良好。谁能指出似乎是问题所在?

import React, {Component} from 'react';
import {productSearch } from '../actions';
import { connect } from 'react-redux';

class SearchResult extends Component {

onSearchBtnClick=()=>{
    this.props.productSearch(this.refs.search.value)
}

selectedProduct(id){
    cookies.set('SelectedProduct', id, { path: '/' });
}

renderItemList(){
    // global state is mapped here
}
render() {
    return(
        <div>
            <h1> SEARCH  PAGE</h1>
            <span>
                <input type='text' ref='search' placeholder='Search Product'/>
                <input type='button' value='Search' onClick={this.onSearchBtnClick}/>
            </span>
            <div>
                {this.renderItemList()}
            </div>
        </div>
    );
};
}

const mapStateToProps = (state) => {
    const searchResult = state.searchResult
    return {searchResult};
}

export default connect(mapStateToProps, {productSearch})(SearchResult);

0 个答案:

没有答案