Hello @Alam, Shahanshah - Contractor {PEP},
welcome to this moderated Azure community forum.
I see both a TypeScript and a Javascript example. Please provide information about the programming language(s) you want to use in React. I expect both are possible...
Connecting a device to an IoT Hub using the Device Provisioning Service is the preferred way.
You need to choice either for single enrollments or group enrollments. Then you need to chose on of the available ways of securing the identity (either a symmetric key or a certificate).
For development and testing purposes, an individual enrollment with a symmetric key is preferred due to simplicity.
Check out this elaborate example based on Node.JS.
It's recommended to try this example as-is first so you prove this example works as expected.
From there, port that solution to you React environment.
Finally, switch over to this X509 example.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.