It's recommended that you wind any yarn into hanks before you dye it. This helps the dye to penetrate evenly, and most importantly, keeps the yarn from getting tangled.
You can find a tutorial on how to make hanks here: www.marthastewart.com/1538644/how-hand-wind-yarn-ball-hank-skein
You can also knit your item up first, and then dye it.