GitHub-Jobs-API-React-App
GitHub-Jobs-API-React-App copied to clipboard
Use checked state of checkbox instead of its value
The value of a checkbox is always empty therefore the query string wouldn't include the value for full_time
. We have to use the checked
state instead.
(The API only filters for full_time=true
, otherwise no filtering is happening. So requesting positions with full_time=false
will return full time jobs as well.)
Correct :)
const handleParamChange = e => {
const param = e.target.name
const value = param === "full_time" ? e.target.checked : e.target.value
setPage(1)
setParams(previousParams => {
return {...previousParams, [param]: value}
})
}