Sorry to combine the two questions here. I am writing a simple search / filtering program. previously there was only my component, so I could easily enter a text value. but now I started to write my part of the container, so I'm confused about how to pass the user value to the action? and my second question is how I will write the 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}) => {
return (
<div>
<input name="search" id="searchbutton" onKeyUp= {nameSearch}></input>
</div>
)
}
export default Search
source
share