Check out example codes for "button width based on text csss". It will help you in understanding the concepts better.

Code Example 1

Remove the width and display: block and then add display: inline-block to the button.

Learn ReactJs, React Native from akashmittal.com