What I'm trying to do: The app I'm working on in React takes two blocks of userinputted text, slices them up into substrings of 30 characters each -- and eventually will randomly recombine these strings. It's a riff on the literary cut-up technique.
Here's what I'm doing:
import React, { useState } from "react";
// import Collage from "./components/collageText/collage";
import "./App.css";
import SrcTxt from "./components/srcTxt/srcTxt";
const App = () => {
const [txt1, setTxt1] = useState("");
const [txt2, setTxt2] = useState("");
const SubmitHandler = (e) => {
e.preventDefault();
setTxt1(e.target.userTxt1.value);
setTxt2(e.target.userTxt2.value);
let cutTxt1 = []
for (let x = 0; x < txt1.length - 31; x + 31){
cutTxt1.push(txt1.slice(x, x+31))
}
console.log(cutTxt1)
};
return (
<div>
<h1>howdy</h1>
<SrcTxt submitted={SubmitHandler} />
</div>
);
};
export default App;
The issue is in how I'm looping through the inputted string. When I run the code, at first nothing logs to the console; if I click submit again, it runs the program infinitely.
I'm pretty sure I'm missing something painfully obvious here.