@@ -22,55 +22,58 @@ interface IModuleEntryProps {
2222 id : string
2323 ) => string ;
2424 renameValidator ?: ( id : string , title : string ) => string | false | null ;
25+ isActive : boolean ;
2526}
2627
27- const ModuleEntry : React . FC < IModuleEntryProps > = ( {
28- module,
29- setCurrentModule,
30- markTabsNotDirty,
31- depth,
32- renameModule,
33- deleteEntry,
34- discardModuleChanges,
35- getModulePath,
36- renameValidator,
37- } ) => {
38- const {
39- state : {
40- editor : { mainModule, currentModuleShortid } ,
41- live,
42- } ,
43- } = useOvermind ( ) ;
44- const isActive = module . shortid === currentModuleShortid ;
45- const isMainModule = module . id === mainModule . id ;
46- const type = getType ( module . title ) ;
47- const hasError = module . errors . length > 0 ;
48- const liveUsers = live . liveUsersByModule [ module . shortid ] || [ ] ;
28+ const ModuleEntry : React . FC < IModuleEntryProps > = React . memo (
29+ ( {
30+ module,
31+ setCurrentModule,
32+ markTabsNotDirty,
33+ depth,
34+ renameModule,
35+ deleteEntry,
36+ discardModuleChanges,
37+ getModulePath,
38+ renameValidator,
39+ isActive,
40+ } ) => {
41+ const {
42+ state : {
43+ editor : { mainModule } ,
44+ live,
45+ } ,
46+ } = useOvermind ( ) ;
47+ const isMainModule = module . id === mainModule . id ;
48+ const type = getType ( module . title ) ;
49+ const hasError = module . errors . length > 0 ;
50+ const liveUsers = live . liveUsersByModule [ module . shortid ] || [ ] ;
4951
50- const isNotSynced = module . savedCode && module . code !== module . savedCode ;
52+ const isNotSynced = module . savedCode && module . code !== module . savedCode ;
5153
52- return (
53- // @ts -ignore
54- < Entry
55- id = { module . id }
56- shortid = { module . shortid }
57- title = { module . title }
58- rightColors = { liveUsers . map ( ( [ a , b , c ] ) => `rgb(${ a } , ${ b } , ${ c } )` ) }
59- depth = { depth + 1 }
60- active = { isActive }
61- type = { type || 'function' }
62- rename = { renameModule }
63- deleteEntry = { deleteEntry }
64- isNotSynced = { isNotSynced }
65- renameValidator = { renameValidator }
66- setCurrentModule = { setCurrentModule }
67- isMainModule = { isMainModule }
68- moduleHasError = { hasError }
69- markTabsNotDirty = { markTabsNotDirty }
70- discardModuleChanges = { discardModuleChanges }
71- getModulePath = { getModulePath }
72- />
73- ) ;
74- } ;
54+ return (
55+ // @ts -ignore
56+ < Entry
57+ id = { module . id }
58+ shortid = { module . shortid }
59+ title = { module . title }
60+ rightColors = { liveUsers . map ( ( [ a , b , c ] ) => `rgb(${ a } , ${ b } , ${ c } )` ) }
61+ depth = { depth + 1 }
62+ active = { isActive }
63+ type = { type || 'function' }
64+ rename = { renameModule }
65+ deleteEntry = { deleteEntry }
66+ isNotSynced = { isNotSynced }
67+ renameValidator = { renameValidator }
68+ setCurrentModule = { setCurrentModule }
69+ isMainModule = { isMainModule }
70+ moduleHasError = { hasError }
71+ markTabsNotDirty = { markTabsNotDirty }
72+ discardModuleChanges = { discardModuleChanges }
73+ getModulePath = { getModulePath }
74+ />
75+ ) ;
76+ }
77+ ) ;
7578
7679export default ModuleEntry ;
0 commit comments