Wednesday, December 1, 2021

React.js: pass variables in different components



In React.js

    setSearchYear = (data) => {
        this.setState({searchYear: data})
    }

              <ApplicationList
                 setSearchYear={this.setSearchYear}
                />

setSearchYear is passed to component ApplicationList, ApplicationList.js

                                   <div className="col-2 text-left form-group">
                                        <Select
                                            id="searchYear"
                                            name="searchYear"
                                            closeMenuOnSelect={true}
                                            components={this.props.animatedComponents}
                                            onChange={value => this.props.setSearchYear( value.value )}
                                            options={this.props.yearList}
                                            defaultValue={[{ label: 'All Fiscal Years', value: 0 }]}
                                        />
                                    </div>
 

No comments:

Post a Comment