Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
Unhandled Runtime Error in react class component when using async function

When I run getData in the following

const FunctionalComponent = observer(): JSX.Element => {
  const { userStore, authStore } = useStores()

  const getData = async (): Promise<void> => {
    const result = await userStore.findById(authStore.id)

    console.log('result in getData', result)
  }

  useEffect(() => {
    getData()
  }, [])
})

I console.log

{
  clientSettings: {test: 'hello'}
}

When I attempt run getData in a React class component like the following

class AUIGrid extends React.Component<Props, State> {

  getData = async (): Promise<void> => {
    const { userStore, authStore } = useStores()
    const result = await userStore.findById(authStore.id)

    console.log('result in getData', result)
  }

  saveColumnLayoutWithOrder = (): void => {
    this.getData()
  }
}

and run saveColumnLayoutWithOrder with

<button onClick={() => {this.saveColumnLayoutWithOrder()}}>save</button>

I get an Unhandled Runtime Error

enter image description here

Why am I getting this error?

useStores explanation edit:

import React from 'react'
import { StoresContext } from '../contexts'
import ContextProps from '@/interfaces/context-props'

const useStores = (): ContextProps => React.useContext(StoresContext)

export default useStores
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!