I am new to programming, and I have such a problem. When entering a set of digits into TextInput for example: "5, 4 ,5, 3, 5" and so on. and sending these numbers to an array located in the Firestore turns out this:
enter image description here
And it should turn out something like this:
enter image description here
What is the problem? Please help me! Here is my code:
const [numberInput, setNumberInput] = useState()
// Sending a value.
const EditSubject = () => {
const addSub = doc(db, 'users', userUID, 'evaluations', 'SecondCours', 'FirstSemestr', 'FirstSemestr');
if (textInput != undefined) {
updateDoc(addSub, {Mathematics: [numberInput]});
setModalWindow(false)
} else {
setModalWindow(false)
}
}
// Getting the value.
<TextInput style={[{backgroundColor: theme.colors.addSubjectText, color: theme.colors.text1}, styles.TInput]} keyboardType = 'numeric' onChangeText={num => setNumberInput(num)}/>
I will be very grateful if you help!
2
Answers
The input code you have shown above is fine. You are rendering the entire numberInput array into a single element of your UI. Try using a map to iterate over the elements of the array and generate a row for each. Your result should look very similar to the linked example, you will just need to add an element for the numbered box.
Edit:
In your section
Displaying a table with subjects, grades, and the result of grades.
you need to make use of the map function. Try this instead:Then, in your main body, you can replace the 4
<Text>
lines with a single div containing the rows component. Hopefully this solves your issues.