title: Vue 3 - inject() can only be used inside setup or functional components
body: <p>I can't understand why I'm getting this error. I am trying to use the Vuex store in a composition function but it keeps throwing me this error about inject (I'm not even using inject). My app makes an await api call to the backend and if there is an error calls my composition function.</p>
  <pre><code>[Vue warn]: inject() can only be used inside setup() or functional components.
  inject    @ runtime-dom.esm-bundler-9db29fbd.js:6611
  useStore  @ vuex.esm-bundler.js:13
  useErrorHandling @  useErrorHandling.js:5
  checkUserExists  @  auth.js:53
  </code></pre>
  <p>Here is my composition function</p>
  <pre><code>import { useStore } from 'vuex'
  
  function useErrorHandling()
  {
      const store = useStore()  // &lt;-- this line
  
      function showError(errorMessage) {
          console.log(errorMessage)
      }
  
      return { showError }
  }
  
  export default useErrorHandling
  </code></pre>
  <p>If I remove this line then it doesn't throw that error</p>
  <pre><code>// const store = useStore()  // &lt;-- this line
  </code></pre>
  <p>UPDATE: this is how the function is called.</p>
  <pre><code>/**
       * Check if a user exists in database
       */
      static async checkUserExists(data)
      {
          const { env } = useEnv()
          const { jsonHeaders } = useHTTP()
          const { showError } = useErrorHandling()
          
          try {
              let response = await fetch(`${env('VITE_SERVER_URL')}/auth/check-user-exists`, {
                  method: 'POST',
                  body: JSON.stringify(data),
                  headers: jsonHeaders,
              })
  
              if (!response.ok) {
                  let errorMessage = {
                      statusText: response.statusText,
                      statusCode: response.status,
                      body: '',
                      url: response.url,
                      clientAPI: 'api/auth.js @ checkUserExists',
                  }
                  
                  const text = await response.text()
                  errorMessage.body = text
  
                  showError(errorMessage) // &lt;-- here
                  return
              }
  
              response =  await response.json()
              return response.user_exists
          } catch (error) {
              alert('Error occured!')
              console.log(error)
          }
      }
  </code></pre>