how react works internally