Reactjs getting the page to refresh with a new JSON API call

Reactjs getting the page to refresh with a new JSON API call
0

#1

reactjs Leaderboard question: Once a page is rendered, how do you get the page to re-render with a fresh new call to the API? In “normal” coding you just recall the function. but it doesn’t seem to be quite that simple in reactjs (feels like I’m learning to code all over again actually!). Here is my codepen - specifically look at what I am trying to do in reloadAndReSortOnClick: function(). Please help!


#2

With React any change to data stored as state in the React component will cause a re-render to occur on the page. So if the data from the API call is stored as state, making the API call again should cause a render to occur to the page.

A major idea in React is to use component state to store all the important information regarding your page or app. State is used as the central point of control, in a way.