-
Notifications
You must be signed in to change notification settings - Fork 50
index parameter is not reset for every iteration #23
Comments
The code I have:
|
Hi, Did you get any solution? |
You are right: |
I wrote a method that returns only one item from the list at a time. Used state to check and reset if list reach to last element. See my solution here: import React, { useState } from "react"; const TickerComponent = props => {
}; return ( TickerComponent.propTypes = { export default TickerComponent; |
I don't have an elegant way to solve this, but I have found a way to solve the issue.
|
As per the below example code:
I expected that the
index
value will be reset based on the number of children elements inside<Ticker>
.However, it seems to be a continuous counter value irrespective of the number of children. Because of this, after the first iteration through all messages, it goes out of bound of messages array - if one keeps messages in an array and use the index.
Either code should be fixed. Otherwise, the documentation needs to be fixed :)
The text was updated successfully, but these errors were encountered: