React update component on state changes
Below is my react component it has two button i want to show list of projects on my page when button is clicked and update that list when other button is clicked but on clicking button second time it not update the list import React, { useState } from "react" import ProjectList from './ProjectList' export default function SearchBar() { const [showProjects , setProjects] = useState('') return ( <div> <div className="container search_project"> <div className="row"> <div className="col-12"> <ul className="list-group list-group-horizontal list-group-flush d-flex flex-wrap" style={{cursor:"pointer"}}> <li itemID="li" className="list-group-item"><span className="text-success"><strong>Select </strong></span></li> <li itemID="li" className="list-group-item" onClick = {() => setProjects("showAll") }> <span>first</span></li> <li itemID="li" className="list-group-item" onClick = {() => setProjects("computerScience")}> second</li> </ul> </div> <div className="col my-4"> <form id = "search-form" style={{paddingBottom: "10px"}}> <div className="input-group"> <input className="form-control" type="text" name = "name" placeholder="Search Project by Name"/> <div className="input-group-append"><button className="btn btn-success" type="submit"><i className="fas fa-search"></i></button></div> </div> </form> </div> </div> </div> {showProjects && <ProjectList projects = {showProjects}/>} </div> ) }