'move caret to the beginning after autofocus

I have an input with autoFocus={true} in React. Things work fine, but I am looking for a way to set the caret to the first position (beginning) right after autoFocus takes effect. I have searched online and only found solutions using JS to change the position of the caret, I wonder whether there is any solution that accommodate autoFocus



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source