Having a weird problem, hoping someone can assist. I'm trying to "iterate" through an array of words and punctuation in order to make the appearance of scrolling dialogue. I have this working except for when I try to push it to React, it just goes...haywire. Here's what I have:
export default function DialogueBox(params){
const params="The story, characters, and events, in this game are entirely fictional. Any similarities to actual people, places and events are entirely coicidental.";
let dialogueValue = [];
let [dialogue, setDialogue] = useState([]);
let letterArray = params.text.split(/\b/);
const handleChangeValue = text => {
const updatedLettersArray = [...dialogueValue, text];
console.log('updated: ' + updatedLettersArray);
// setDialogue(oldArray=>[...oldArray,updatedLettersArray]);
}
return (
<div className="dialogueBox">
{letterArray.forEach(function(element,index){
setTimeout(
function(){
handleChangeValue(element);
dialogueValue.push(element);
}, index * 500
);
})}
<p>{dialogue}</p>
</div>
)
}
Here's the console log, which is correct:
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, ,story,, DialogueBox.js:15
updated: The, ,story,, ,characters DialogueBox.js:15
updated: The, ,story,, ,characters,, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, ,are DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, ,are, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, ,are, ,entirely DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, ,are, ,entirely, DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, ,are, ,entirely, ,coicidental DialogueBox.js:15
updated: The, ,story,, ,characters,, ,and, ,events,, ,in, ,this, ,game, ,are, ,entirely, ,fictional,. ,Any, ,similarities, ,to, ,actual, ,people,, ,places, ,and, ,events, ,are, ,entirely, ,coicidental,.
but, if I uncomment that line
// setDialogue(oldArray=>[...oldArray,updatedLettersArray]);
the following happens:
updated: The 94 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 3 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 3 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 3 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 3 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 3 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, 2 DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story 3 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story 3 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story 2 DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story 2 DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The DialogueBox.js:15
updated: The, ,story DialogueBox.js:15
updated: The, DialogueBox.js:15
updated: The, ,story
Basically just repeating itself non stop. I'm positive i'm missing something obvious here but i'm at a loss! Thank you all for any help
paramsand then also declaring a variable namedparams?