I have done tutorials and have seen examples where the array list item that is dynamically generated works exactly as intended. For some reason, in the code I am having to map in this particular array list is not generating the array list in any discernible order.
Reason being... From what I seen every time an action is added the key and index and other parameter is "adjusted" on the fly... leading to something completely random.
***Updated the description to be much more accurate to what is occuring based on my code base. I have learned we are using imuttable.js More info here https://facebook.github.io/immutable-js/ and because of this there are certain things happening prior to the object being mapped...
For example we are using filter for a json object in our this.props
it is written as follows:
const filteredConstant = jsonObjects.filter((jsonObject) => {
return (jsonObject.status === status.APPROVED)
}
From the documentation in immutable it says filter will do the following
Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0)
// Seq { b: 2, d: 4 }
From here we can rework the const / variable and now use map() to map the object. The below code did not work in the sense that open adding items to the object of jsonObject2 would produce random results. The key and even if I added an index there would be no rhyme or reason as to what the order would be... intended result would be oldest - newest data entry or ascending.
filteredConstant.valueSeq().map((jsonObjectNew, //index) => {
// code here
key={jsonObjectNew.id} //index={index} (//doesn't work either way)
}
apparently valueSeq() doesn't have an affect. Introducing a timestamp appended to a unique id doesn't work either.
Like I said previously it seems as if every-time there is a new entry it "remaps" and thus reorders randomly what is going on. I could be interpreting what the key actually is... I still haven't figured out how and where the key is being generated ideally from the server side. But even in terms of a key that is base64 for example would still have to go in some type of order based on letters and numerics? Am I wrong to think this?
Alas, I was able to create a fix and I will share that below. But more insight into this would be appreciated.
In jsfiddle I cannot replicate the issue but if any help can be offered on what exactly controls the array order and or new data entering into the object would said action have on the effect of the overall order?