Error: React Hook "useCallback" is called conditionally. React Hooks must be called in the exact same order in every component render

You need to move your useCallback definition to above the if (model) check. This if block may cause your component to render before the function has been memoized by useCallback.