Skip to content

Instantly share code, notes, and snippets.

@e-schultz
Created August 20, 2019 15:52
Show Gist options
  • Select an option

  • Save e-schultz/e62de0dd18cbcf4aaa32962e071d3fe1 to your computer and use it in GitHub Desktop.

Select an option

Save e-schultz/e62de0dd18cbcf4aaa32962e071d3fe1 to your computer and use it in GitHub Desktop.
component - hook - lifecycle post
export default SomeComponent = ({id, filter}) => {
let [results, setResults] = useState([]);
useEffect(()=>{
fetch(`/some/url/${id}?filter=${filter}`)
.then(r=>r.json())
.then(r=>setResults(r))
},[id, filter])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment