Skip to content

Commit

Permalink
ref(articulation): Refactor useArticulationTable to require React as …
Browse files Browse the repository at this point in the history
…a dependency
  • Loading branch information
Grafikart committed Dec 30, 2024
1 parent de29925 commit 9f2a41d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/hooks/useArticulationTable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type LunaticSource, getArticulation } from '@inseefr/lunatic'

import { type ReactNode, useEffect, useState } from 'react'
import { type ReactNode } from 'react'
import type React from 'react'

import { prCore } from '@/createCore'

Expand All @@ -17,11 +18,16 @@ type TableData = {
/**
* Generates table data for articulation
* Used to get the progress of a surveys containing a roundabout
*
* To ensure the host use the same version of React we require it as a dependency of this function
*/
export function useArticulationTable(surveyUnitId: string) {
const [data, setData] = useState<TableData | null>(null)
export function useArticulationTable(
react: typeof React,
surveyUnitId: string,
) {
const [data, setData] = react.useState<TableData | null>(null)

useEffect(() => {
react.useEffect(() => {
;(async () => {
// Retrieve questionnaire source and survey unit data
const { collectSurvey } = (await prCore).functions
Expand Down

0 comments on commit 9f2a41d

Please sign in to comment.