Some mushrooms blacken during cooking because of changes in biological enzymes, which is a normal phenomenon, such as ashwagandha, black fungus and other mushrooms, while some mushrooms blacken during cooking because of the aging of the substrate, such as Agaricus bisporus will have such a phenomenon.
The former blackened can be consumed normally, while the latter is recommended not to consume because the flavor has changed and lost its edible value.