How to pass input field value into reduction reaction

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}) => {
   // const {search,value} = this.props

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



export default Search
+4
source share
1 answer

I got my answer from here , so I changed my .js search as follows

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

     </div>
)
+3
source

Source: https://habr.com/ru/post/1681821/


All Articles