One of the great things about Gandhi was that he evolved as a person as he aged. He worked in South Africa as a young(er) man, his views on Black people changed as he grew older.
Regardless, Gandhi's writings about Black people have been taken out of context in many places, and it would be a good idea to read entire letters/articles written by him before jumping to conclusions.