It's fascinating to me that Beethoven composed some of his best music after he lost his hearing. I assume it was gradual and so he could probably get by for a while, but at some point he was completely deaf yet he could still compose music. Was he able to just do everything from memory?
Your assumption is correct - Beethoven's hearing loss was indeed gradual, over the course of years. He was fairly young, in his late 20s, when it began, but was already an accomplished musician and composer. Memory is what allowed him to continue composing; most composers rely as much or more on their mental image as the actual piano or other instrument they're composing for. The director of the California Symphony has described music as "a language with rules," and as Beethoven knew the language and its rules, he could keep composing even without hearing it.^1
(Reportedly he also used a pencil to help transmit vibrations while working.)^2
Another composer who became deaf, Bedřich Smetana, is another excellent example of using memory as an aid to the work.^3
Indeed, most classical composers who produced works while deaf became deaf later in life. Although other songwriters, such as Sean Forbes and the members of Beethoven's Nightmare, have been deaf from much younger ages, I am not aware of any classical composers who were prelingually deaf.
On a related note, if you aren't familiar with the story of Mamoru Samuragochi, [this] (https://newrepublic.com/article/121185/japans-deaf-composer-wasnt-what-he-seemed) is a good read. I cannot in good conscience call him a deaf composer (as it seems he is neither), but it's an interesting story.