Let G : R -R be a continuous function. Under some assumptions on G, s, alpha, p and q we prove that {G(f) : f E Asp,q(Rn,|center dot|alpha)} c Asp,q(Rn,|center dot|alpha) implies that G is a linear function. Here Asp,q(Rn, | center dot |alpha) stands either for the Besov space Bsp,q(Rn, | center dot |alpha) or for the Triebel-Lizorkin space Fsp,q(Rn, | center dot |alpha). These spaces unify and generalize many classical function spaces such as Sobolev spaces with power weights.