use-mounted

mounted hook that allows to return promises

Usage no npm install needed!

<script type="module">
  import useMounted from 'https://cdn.skypack.dev/use-mounted';
</script>

README

npm install use-mounted

Converts

useEffect(() => {
    const fetchData = async () => {
        // await fetch('endpoint')
    }

    fetchData()
}, [])

to

import useMounted from 'use-mounted'

useMounted(async () => {
    // await fetch('endpoint')
})