Search code examples
javascriptreactjsjsxvis.jsvis.js-timeline

Vertical List from string array


render(){
        const { data } = this.props

        const newArray = data.abs.map((abs, index) => ({id: index + 1, content: abs.event.toString, start: abs.times, title: abs.trs, end: null}) )


        var container = document.getElementById('timeline');


          return(              

            <div className="timeline">
                <Timeline 
                    //groups={groups}
                    items={nArray}
                    options={options}
                    container={container}


                  />;

            </div>
          )//return

      }//render

The above displays the results as: ["item1","item2","itme3"]. However, I would like this:

item1,
item2,
item3

I tried .split() but React is saying .split() is not a function. I also tried JSON.stringify(abs.event, null 2) but it does work. Any help would be greatly appreciated.


Solution

  • your results displays as : ["item1","item2","itme3"]

    Once try: ["item1","item2","itme3"].join(",<br>");

    it may help you.