0

I have been following the tutorial for using Fixed Data Tables with React.

http://facebook.github.io/fixed-data-table/

Everything seems cool although the tutorial has a small amount of JSON directly in the app and not from an external source. I am looking to import mine from a github gist

the code i have so far is below.

I know i'm not pulling it in entirely correctly here so any help would be appreciated.

thanks

const rows = 'https://gist.githubusercontent.com/theuser/fwqgfwrgqw/raw/qwfefwqefrgthgtwg81bba6df90f46eaa5e7681c13/programmes.json'; ReactDOM.render( <Table height={rows.length * 30} width={1150} rowsCount={rows.length} rowHeight={30} headerHeight={30} rowGetter={function(rowIndex) {return rows[rowIndex]; }}> <Column dataKey="id" width={50} label="Id" /> <Column dataKey="name" width={200} label="Name" /> <Column dataKey="shortDescription" width={200} label="Description" /> <Column dataKey="active" width={400} label="Active Status" /> </Table>, document.getElementById('example') ); 

below is an example of the JSON

{ "id": 1938, "slug": "drivers-rebooted", "name": "test one", "shortName": "test one", "shortDescription": "Another look at some of the nation's oldest drivers.", "longDescription": "Another look at some of the nation's oldest drivers, including 102-year-old test yser who is determined to stay on the road - despite being barely able to hear.", "active": true, "type": "generic", "defaultExpiry": 30, "availableEpisodes": 2, "images": [ { "id": 456025, "filename": "456025-100-year-old-drivers-rebooted.jpg", "masterFilepath": "456\/", "_filepath": "http]" } ], }, 
3
  • Your problem here is that all you are doing is setting rows to be a string of the URL to the JSON. You are not actually fetching the JSON object from the URL. Try looking at this article stackoverflow.com/questions/25871433/load-external-json-file Commented Nov 24, 2016 at 17:38
  • @ChrisBlakey forgot to add in, would prefer this is done without jQuery as well. I'm trying to improve my Javascript. Should i download the json locally and try adding it at the head of the file import data from './data.json'; for example Commented Nov 25, 2016 at 11:57
  • Yes that would work fine if you download locally. If it needs to be remote there will be other options without using jQuery, but what route to take will very much depend on how you are structuring your application, is there a data layer with your back end server etc... it can be achieved in many ways. Commented Nov 25, 2016 at 12:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.