I would imagine a similar solution would work for just about any of the same circumstances, not just Ad-Sense.

One common misconception is that people often think they can put a script tag in a dangerouslySetInnerHTML attribute and that is not the case. It's using setInnerHTML which will not execute script tags.