code challenge deployed to github pages: https://zw896.github.io/form-component/
- JSON data is a nested array, result should be an object.
- Store the id value in dataElements into an new object as the key with "" empty value, so it should be
problem: how to create this new object based on "dataElements"?
{ "name": "", "gender": "", ...etc. }
- one parent component: DynamicForm, which contains a child component: Input.
- Parent component DynamicForm has initial state which contains the data read from JSON file given.
- Pass the data to child component Input as props.
- In Input component, determine which the input type is: input/number or select. Using react-select for select tag.
- handleChange/handleSelectChange functions handle the input value from users.
- Submit button outputs the final object to console.
- Validate input value that been received.
- Output error messages.
- Create a parent component: DynamicForm
- Create a child component: Input
- In DynamicForm
- Accept user input
- Submit user input
- Output the final object to console
- Validate user input
- Error message
- Switch form button
- Calculate bmi value