yardz commented on pull request #13497: URL: https://github.com/apache/superset/pull/13497#issuecomment-795464329
> Did you count all the hooks you created though? I did the same and got 21 non-test files and 700 LOC: https://gist.github.com/ktmud/f5c16eb18bbceda2fd3f998d14f18948 Yes, but I just compared the "code body". I removed the imports and the declaration of methods like this: ``` Removed: --> import React, { useEffect, useRef } from 'react'; --> --> import { OnSelectChange } from '../onSelectChange'; --> import { factoryChangeSchema } from './factoryChangeSchema'; --> --> export const useChangeSchema = ({ --> setCurrentSchema, --> onSchemaChange, --> getTableList, --> onSelectChange, --> }: { --> setCurrentSchema: (schema: string | undefined) => void; --> onSchemaChange?: (arg0?: any) => {}; --> getTableList?: (dbId: number, schema: string, force: boolean) => {}; --> onSelectChange: React.MutableRefObject<OnSelectChange>; --> }) => { --> const changeSchema = useRef( --> factoryChangeSchema({ --> setCurrentSchema, --> onSchemaChange, --> getTableList, --> onSelectChange, --> }), --> ); useEffect(() => { changeSchema.current = factoryChangeSchema({ setCurrentSchema, onSchemaChange, getTableList, onSelectChange, }); }, [getTableList, onSchemaChange, setCurrentSchema, onSelectChange]); return changeSchema; }; ``` How I basically moved existing code to an external function. > It was almost 700 lines vs 270 lines. Better than my original estimate, but still... it's also 21 files vs 1 file... I can't imagine opening 21 files just trying to understand this one component. 21 are with the test files. But yes, they are much more files. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
