Building a Body Mass Index Calculator with ReactJs using basic class-based components,state and props.
BMI is a measurement of a person's leanness or obesity based on their height and weight. BMI is a measurement of a person's health and wellbeing. The value that is obtained is used to identify whether a person is underweight,overweight, or obese depending on the range the value falls between.
The Body Mass Index (BMI) Calculator can be used to calculate BMI value which is based on the height of the person.Gender also plays a significant role in determining the health of the individual.
Here is a basic BMI Calculator built using ReactJS.
COMPONENT
A component in React allows us to split the page into independent and reusable parts. This project comprises three main class-based components – the main App components and two other components namely BmiCalc and Result.
STATE and PROPS
This project also demonstrates the state system in react. A state is an object which is added as a property in class components. It allows components to manage /change data.
The above code is an example of using state.
React allows us to pass information to a component from another parent component using props (properties). Props are kind of global variable or object and are read-only, that is, components cannot change the value of their props.
Submitted by Harshita Shree (harshita)
Download packets of source code on Coders Packet
Comments