0
Could someone help me.
Sane 4 inputs on the screen where the person enters with the notes. I am doing the following, I take the value of each input and play within an array to add up later.
However the array with Onchange and Oninput the array is as follows:
input1 = 10 input = 20
array = ['1', '10']
I want it to stay that way
array = [10, 20]
I put as text the input and want to transform with parseint to numeric, however I could not do ?
Guys, I tried to explain as best I could, I saw that you already gave a -1, but I’m new I’m learning, I hope the staff instead of wanting to close the question or putting -1, help who is starting, I hope it’s well explained, I made a code sketch hope it helps, if there is something wrong tell me, we are here to help and the feedback is worth a lot.
import React, { Component } from "react";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
text: "",
notas: [],
};
}
input = (e) => {
this.setState({
[e.target.name]: e.target.value,
});
const array = this.state.notas;
array.push(this.state.text);
this.setState({
notas: array,
});
console.log(this.state.notas);
};
render() {
return (
<div>
<input type="text" name="text" onChange={this.input} /> <br />
{this.state.text} <br /><br />
{this.state.notas.map((n, index) => {
return <p key={index}>{n}</p>;
})}
</div>
);
}
}
The answer came true Daniel?
– novic
Thanks Novic helped yes, but I still have some problems, I even reformulated the question, I’m trying to do here since yesterday but I’m a little lost. But thank you very much.
– daniel
You cannot tailor your question to a new doubt, this is not allowed here
– novic
If you have too many doubts, create a new question, as I repeat, it is not valid.
– novic
The doubt is still the same
– daniel
You have not changed to suit for a new answer, it is not valid.
– novic
No, I rephrased the question by putting more details, but she is the same as before, so much so that at first and I put several doubts and with.
– daniel
Daniel I answered your initial question and you were not satisfied because, comment?
– novic