WD-40 is a degreaser. The common mistake is using it in the place of grease. it'll work in the short-term but all it is doing is cleaning up and removing the old dirty grease. eventually you'll end up with metal against metal.
my ritual for cleaning a chain is to soak it in a can of kerosene for a few days, hang it up, shoot it with the garden hose for awhile, dry it with a heat gun or torch, once it's cooled down, lube it with pro-link.