What exactly does render() do

Iam trying to build my first React App and thought I understood what render() is doing. I just stumbled over the following, when I checked how to build a table with react-table. I dont understand, why I need to put my const data into the render.

tutorial says:

import ReactTable from 'react-table'

render() {
  const data = [{
    myData
  }]

  const columns = [{
    myColumns
  }]
}

return <ReactTable
    data={data}
    columns={columns}
  />
}

why does this not work?

import ReactTable from 'react-table'

const data = [{
    myData
  }]

const columns = [{
    myColumns
  }]

  return <ReactTable
    data={data}
    columns={columns}
  />
}