File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
src/apps/copilots/src/pages/copilot-request-form Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 1
- import { FC , useContext , useEffect , useState } from 'react'
1
+ import { FC , useContext , useMemo , useState } from 'react'
2
2
import { bind , isEmpty } from 'lodash'
3
3
import { toast } from 'react-toastify'
4
4
import classNames from 'classnames'
@@ -21,21 +21,18 @@ const CopilotRequestForm: FC<{}> = () => {
21
21
const [ isFormChanged , setIsFormChanged ] = useState ( false )
22
22
const [ formErrors , setFormErrors ] = useState < any > ( { } )
23
23
const [ searchTerm , setSearchTerm ] = useState < string > ( '' )
24
- const [ projects , setProjects ] = useState < InputSelectOption [ ] > ( [ ] )
25
24
const { data : projectsData } : { data ?: Project [ ] } = useFetchProjects ( searchTerm )
26
25
const [ existingCopilot , setExistingCopilot ] = useState < string > ( '' )
27
26
const [ paymentType , setPaymentType ] = useState < string > ( '' )
28
27
29
- useEffect ( ( ) => {
30
- if ( projectsData ) {
31
- setProjects (
32
- projectsData . map ( project => ( {
33
- label : project . name ,
34
- value : project . id ,
35
- } ) ) ,
36
- )
37
- }
38
- } , [ projectsData ] )
28
+ const projects = useMemo (
29
+ ( ) => (
30
+ projectsData
31
+ ? projectsData . map ( project => ( { label : project . name , value : project . id } ) )
32
+ : [ ]
33
+ ) ,
34
+ [ projectsData ] ,
35
+ )
39
36
40
37
const projectTypes = ProjectTypes ? ProjectTypes . map ( project => ( {
41
38
label : project ,
You can’t perform that action at this time.
0 commit comments