0

I am trying to display multiple (approximately 10) images in a modal by looping through the each of them. The modal opens after clicking on the link present in a table cell, but nothing shows in the modal.

When I display only 1 image, then it gets displayed in modal. I am using React.js for the first time. Please help me with the solution to my problem. Thanks in advance.

    }, {
        Header: 'Screenshot',
        accessor: 'screenshot',
        maxWidth: 100,
        Cell: row => {
            if (row.original.screenshot)
                var array = [];
            for (var i = 0; i < row.original.screenshot.length; i++) {
                array.push = <img src={"data:image/png;base64," + row.original.screenshot[i]} />
            }
            var Image = array.join('');
            return <a onClick={() => {
                this.setState({
                    screenShotModalOpen: true,
                    screenShotImage:
                        <div>
                            {Image}
                        </div>
                })
                    href={'javascript:void(0)'}>View</a>

            }}
        },
    }],
}]
Christopher Bradshaw
  • 2,615
  • 4
  • 24
  • 38
TThakur
  • 13
  • 3

1 Answers1

0

For your if statement in line 169, add curly braces. If you have multiple lines in your if statement, then curly braces are required. Do 'if' statements in JavaScript require curly braces?

Jordan Daniels
  • 4,896
  • 1
  • 19
  • 29