how to pass input box value to action in react-redux

Viewed 2757

sorry for combining 2 questions here. I am writing simple search/filter application. previously only my component was present so I was able to input text value easily. but now I started writing my container part,so I am confused that how should I pass user value to the action? and my 2nd question how will I write fetched result back to my page

here is my SearchContainer

import Search from "../components/Search"
import React from "react"
import {connect} from "react-redux"
import {search} from "../action/SearchAction"
import {bindActionCreators} from 'redux';
const SearchContainer = ({search}) =>(
    <Search nameSearch={(value) => search(value)}/>
)
const mapDispatchToProps= (dispatch) => (
 bindActionCreators({search},dispatch)
)
const mapStateToProps= state => {
    console.log("state",state)
    return{
    results:state.searchResult.values
    }
}

export default connect(
     mapStateToProps,
    mapDispatchToProps

) (SearchContainer)

here is my search page

import React from "react"
import Select from "react-select"
import {connect} from "react-redux"


const Search = ({nameSearch}) => {
   // const {search,value} = this.props

    return (
    <div>
        <input name="search"  id="searchbutton" onKeyUp= {nameSearch}></input>
     </div>
    )
}



export default Search
1 Answers
Related