I have a dropdown searchbox that I want to use to display results and I have a card component that I want to display when the dropdown value matches the value of the user the card component is for.
I have retrieved the state of the user from props and compared this with the state of the dropdown to create the function onSearchSubmit to display the card component 'ProfileCard'.
When testing the onSearchSubmit function using console.log, the if statement is true however the ProfileCard component does not display. There are no errors, I just can't see my component being displayed.
Any help will be greatly appreciated. This is my first question on here so if there is not enough information I will try and help as much as I can.
Please see code below. (I have omitted sections of the code I don't think is related to this section).
onSearchSubmit = () => {
if (this.state.selectedCategory === this.props.category) {
console.log('it works')
return ( <ProfileCard/> );
} else {
console.log('not working')
}
}
render() {
return (<div>
<button onClick = {
this.onSearchSubmit
}> Search</button>
</div>
)
}
Thanks,
John