I know that this is true for real-valued functions. However, the proof is based on the mean value theorem and the latter is not valid for complex-valued functions (here is a counter-example).
That being said, the following generalization was proven in one of my lectures:
Let $V$ and $W$ be normed vector spaces over the same field $F$. Let $U\subset V$ be open and connected, then a map $f\colon U\to W$ is constant iff $Df(x)=0$ for all $x\in U$, where $Df(x)\in L(V,W)$ is the Fréchet-derivative.
In the title of my question, I consider the case $V=\mathbb{R}$ and $W=\mathbb{C}$. The problem is that the Fréchet derivative is not defined when $V$ is real vector space and $W$ is a complex vector space, since the set $L(V,W)$ is only defined when $V$ and $W$ are vector spaces over the same field.
Is there another definition of the derivative in this situation and does it allow a similar theorem?
I found an answer for the case $V=\mathbb R$ and $W=\mathbb C$. Yes, there is a similar theorem.
Lemma. $f\colon U\subset\mathbb R\to\mathbb C$ is differentiable if and only if $u:=\text{Re}f$ and $v:=\text{Im}f$ are differentiable and $f'=(u+iv)'=u'+iv'$.
Corollary. $f'=0\Leftrightarrow u'=0$ and $v'=0\Leftrightarrow u$ and $v$ are constant $\Leftrightarrow f$ is constant.
Proof:
To proof the Lemma, we prove the following two Lemmas:
Lemma 1. If $u,v\,\colon U\to\mathbb R$ are differentiable, $f=u+iv$ is differentiable and $f'=u'+iv'$.
Proof. \begin{equation} \left|z-\frac{f(a+\delta)-f(a)}{\delta}\right|\leq\left|x-\frac{u(a+\delta)-u(a)}{\delta}\right|+\left|y-\frac{v(x+\delta)-v(x)}{\delta}\right| \end{equation} Lemma 2. If $f$ is differentiable, $u:=\text{Re}f$ and $v:=\text{Im}f$ are differentiable and $f'=u'+iv'$.
Proof. \begin{equation} \left|x-\frac{u(a+\delta)-u(a)}{\delta}\right|=\left|\text{Re}\left(z-\frac{f(a+\delta)-f(a)}{\delta}\right)\right|\leq\left|z-\frac{f(a+\delta)-f(a)}{\delta}\right| \end{equation} \begin{equation} \left|y-\frac{v(a+\delta)-v(a)}{\delta}\right|=\left|\text{Im}\left(z-\frac{f(a+\delta)-f(a)}{\delta}\right)\right|\leq\left|z-\frac{f(a+\delta)-f(a)}{\delta}\right| \end{equation}