As the other posters have already said, research is always key. Read lots, listen to people, make sure your treatment of the subject matter is enlightening, but not too patronizing, nor dwells too much on the topic that it becomes heavy-handed and clumsy.
What I'd add, probably, is that one should try not to define the character by their disorder. The line sometimes blurs between the person's true self and the mental illness, but the line nonetheless exists. Make sure that what you're writing is a person, with an identity, with his/her due share of flaws and triumphs that is not dictated by what they're diagnosed with. As much as possible, avoid pigeonholing them into neat character descriptors, and instead develop them as if they were real people with real hopes and dreams, because of and despite their conditions.
Not everyone can pull it off well, and not for lack of trying. I've seen series here on Tap where people slap on disorders on their characters just to label them "different" from the rest, without fleshing out any other facet of their characters beyond that, which is just offensive to people with actual disorders. Mental illness is NOT a fashion accessory.
This topic is especially relevant to me given that I'm writing for Missing Stars, a visual novel where you romance girls with mental illnesses. From the premise alone, it's clear we're dancing on a minefield, but we have a team of medical consultants to make sure our portrayals are accurate and realistic, and our whole team is working hard to make it an honest and heartfelt story.