Pick $X$ such that there are path-components $Y \neq Z$, and $y \in Y$, $z\in Z$ with the conditions: $y$ belongs to the interior of $Y$, $z$ belongs to the interior of $Z$, and $Y$ is not a singleton.
Choose $x\in Y\smallsetminus\{y\}$. Then we can't approach with continuous maps a map mapping $x \mapsto z$ and $y \mapsto y$. Indeed, a map close enough should map $y \mapsto y'$, $x \mapsto z'$ with $y'\in Y$, $z'\in Z$. The image of a path joining $x$ to $y$ would thus join $y'$ to $z'$, contradiction.
Now it's easy to find a compact connected subset of the plane with these conditions. For instance, the closure of the graph $W$ of the function $[-1,1]\smallsetminus\{0\}\to [-1,1]$ mapping $x\neq 0$ to $\sin(\pi/x)$, which is connected with 3 path-components (the two connected components of $W$, and the segment $\{0\}\times [-1,1]$), with $y=(-1,0)$, $z=(1,0)$.