1

The percise error I'm getting (when I start to type in textbox) in my log is:

Uncaught TypeError: _this.props.setTextFilter is not a function
at ExpListFilters._this.onTextChanged (ExpListFilters.js:17)

Here is my function:

onTextChanged = (e) => {
        this.props.setTextFilter(e.target.value);
    };

Rendered inside component:

<div className="in-group__item search-box">
<input placeholder="Search for your expenses" 
className="text-input" 
type="text" 
value={this.props.filters.text} 
onChange={this.onTextChanged}/>
</div>

Also using redux to map state to props by passing down filters from actions.

import { setTextFilter } from '../actions/filters'

Redux:

const mapStateToProps = (state) => ({
        filters: state.filters
});

1 Answer 1

1

I wasn't using mapDispatchToProps while exporting the component (using connect), see below.

Previous

export default connect(mapStateToProps)(ExpListFilters);

Updated

export default connect(mapStateToProps, mapDispatchToProps)(ExpListFilters);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.