My version of FreeCodeCamp Leaderboard

Take a look at my version of FreeCodeCamp Leaderboard:
Using React.js, AJAX requests with fetch(), stateless functions, Sass, Babel, Webpack. You can find full version of the project on GitHub:

1 Like

This isn’t working for me on an iPhone - I get the table headers, but no rows…

Thank you for pointing me this!
That’s true - because I’m using fetch() for AJAX requests and it hasn’t a support for all browsers yet. But in my full version(code on GitHub) I’m using fetch polyfill and it should work well for all browsers including Safari 6.1+

I suspected that…I just started using fetch today and had the same issue :slight_smile:

I don’t want to peek at your code as I haven’t finished it yet, but did you string a bunch of promises together in your fetch().then() chain and stick your react DOM render call in there, or did you handle it a different way?

That’s how I’ve done it so far, but I’m pretty dissatisfied with it…

I don’t understand well what do you mean as [quote=“JacksonBates, post:4, topic:22601”]
stick your react DOM render call in there
I use fetch() inside componentDidMount function for my Leaderboard component(which I use for handling state of my app)

let APICampers = [];

.then((response) => response.json())
.then((data) => APICampers = data)
.then(() => {
  for (let i = 0; i < APICampers.length; i++) {
    APICampers[i]["rank"] = i + 1;
.then(() => {
  const app = document.getElementById('app');
  ReactDOM.render(<CamperTable campers={APICampers} />, app);

I haven’t heard of your method, I’ll look into it :slight_smile:

No, I do it another way - first .then as you(for parsing json) - and only one more .then for saving data inside state object using setState