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

99
Views
use route parameter in the Redux Saga file

How to pass current route parameters to the saga function?

enter image description here

// Saga
 function* findOneReleaseWithFilesSaga() {
   const { productName, releaseId } = useParams()
   try {
     const releaseResponse: AxiosResponse = yield call(findOneWithFiles, releaseId)
                                                       ^^^Error Here^^^
     yield put(getAllReleasesSuccessAction(releaseResponse))
   } catch (error) {
     yield put(getAllReleasesErrorAction(error))
   }
 }

// Fetch Data
 export const findOneWithFiles = async (releaseId:string) => {
   return await Api.get(`/releases/${releaseId}/?populate=data_files`)
     .then((res) => res.data.data)
     .catch((err) => err)
 }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think the issue in the type of releaseId you get from useParams. Make sure it is a string. Also the desctructuring might be a problem, there were some fixes for that in TS4.6, but assuming you are on older version I would try to assign to a variable instead:

const params = useParams()
yield call(findOneWithFiles, params.releaseId)

On a side note, I would avoid prefixing a function with use unless it is a react hook.

about 4 years ago · Juan Pablo Isaza Report
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!