How was it handled?
How did it affect their presidency?
A similar question was asked before, and got some good responses: https://www.reddit.com/r/AskHistorians/comments/2dzgb9/are_there_any_us_presidents_who_suffered_from/
But they mostly didn't answer your second and third questions, so I'll try with Lincoln.
Anything I don’t attribute is from Lincoln’s Great Depression, by Joshua Wolf Shenk for The Atlantic. The article talks at length about the questions you asked. It also briefly talks about the waves of historians who wrote about Lincoln, the angles they took, and the things they left out.
By all contemporary accounts, Lincoln suffered from major (clinical) depression. He talked about contemplating suicide, and was known to have written a poem about suicide. (Probably this poem, though that can’t be proven).
"No element of Mr. Lincoln's character," declared his colleague Henry Whitney, "was so marked, obvious and ingrained as his mysterious and profound melancholy." His law partner William Herndon said, "His melancholy dripped from him as he walked."
How was it handled?
One early account of evidence of his depression is how he handled the death of his friend, Ann Rutledge.
Henry McHenry, a farmer in the area, recalled, "after that Event he seemed quite changed, he seemed Retired, & loved Solitude, he seemed wraped in profound thought, indifferent, to transpiring Events, had but Little to say, but would take his gun and wander off in the woods by him self, away from the association of even those he most esteemed, this gloom seemed to deepen for some time, so as to give anxiety to his friends in regard to his Mind."
He made jokes, told stories, laughed, and played. But he also recited poems about death instead of singing when asked, and did other disturbing things when surrounded by people.
Lincoln said that his “melancholy” was not caused by himself and his actions. So to try to combat it, he took various things like cocaine and “blue pills”, the main ingredient of which was mercury. It has been argued that he suffered from “neurobehavioural consequences of mercury intoxication”, but that he recognized something was wrong and stopped taking the pills before becoming president.
But maybe the most important things that Lincoln did about his depression were to be open about it with friends, and to do work. Reading through his life stories as told by others, it’s obvious that a lot of people knew that Lincoln was affected by “melancholy”. He talked about it and told others when he was feeling especially low.
How did it affect his presidency?
There were no 24/7 news networks. It was much easier for a president’s mental health to go unnoticed by the general public.
So the other ways that it affected his presidency will get into speculation territory. You can argue that without his depression he wouldn’t have become president in the first place. Depression affects people in different ways, and for Lincoln, it gave him humility and the drive to make something of his life.
For more on that, I’d recommend reading the Atlantic article I linked earlier.
The example that springs to mind is Woodrow Wilson, who lost his wife early in his Presidency and suffered from a deep depression for many months while in office.
I've read this in several places, but if you want some info on Wilson's depression (along with a lot of other things), you might look into Erik Larson's "Dead Wake".
I know this mostly as an offshoot of my enthusiasm for the first world war-a "proper" historian can surely provide more detail. Indeed, I hope they will, as I'd like to learn more about it myself.
There is considerable question about whether Reagan was suffering from the early effects of Alzheimer's during the late stages of his presidency. There was an interesting article on this recently in the New York Times. It also notes that questions as to Reagan's mental capacities as the oldest US President were discussed issues during his two election campaigns.