Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

if the params of usequery updated

const FetchPosts = async ({criteria}) => {
    console.log(criteria) //from useQuery key

    //your get api call here with criteria params

    return posts;
};

const [criteria, setCriteria] = useState("")

const {isLoading, data: post} = useQuery(["posts", criteria], FetchPosts); //include criteria state to query key

console.log(post) 

<select
  name="filter"
  value={criteria}
  onChange={(e) => {
    setCriteria(e.target.value);  // trigger a re-render and cause the useQuery to run the query with the newly selected criteria
  }}
>
  <option>Most recent First</option>
  <option>Price: Low to High</option>
  <option>Price: High to Low</option>
</select>
Comment

PREVIOUS NEXT
Code Example
Javascript :: jsdoc run for all files in folder 
Javascript :: select inputs without specific type js 
Javascript :: realtime database get by field 
Javascript :: react-social-login-buttons 
Javascript :: filter by last week 
Javascript :: Expo Location Error: Unhandled promise rejection: Error: Not authorized to use background location services 
Javascript :: laravel , json Why it shows Cannot access offset of type string on string error 
Javascript :: javascript Why is this function working on second click only 
Javascript :: how will you get all the matching tags in a html file javascript 
Javascript :: ziggy vue 3 
Javascript :: Make a card dynamic with Angular JS 
Javascript :: angularjs How to add row after the last row in ng2 smart table 
Javascript :: AngularJS - get previous selected option after ng-click on a ng-repeat 
Javascript :: How to get one items from my Firebase realtime Database with Angular Ionic 
Javascript :: Calculating state happens to late 
Javascript :: Check if a user joins, leaves, or moves channels discord.js 
Javascript :: supertest npm send headers node js 
Javascript :: react select disable 
Javascript :: Using javascript code in Jade views - if(variable) shows undefined instead of passing 
Javascript :: get oinput value clojurescript 
Javascript :: Declare JSON Variable In Another File 
Javascript :: "Uncaught (in promise) TypeError: dispatch is not a function" 
Javascript :: Class Which Can Create An Instance Of The Same Type 
Javascript :: This Refers To The Window Object Here 
Javascript :: react sate and props 
Javascript :: parseint javascript online 
Javascript :: react-native navigation homeStack 
Javascript :: path.join javascript one folder above 
Javascript :: stringToCapital.js 
Javascript :: expact 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =