Problem Rendering an API on a Bootstrap Table with ReactLoop inside React JSXReact “after render” code?Set focus on input after renderWhat is the difference between using constructor vs getInitialState in React / React Native?What do these three dots in React do?Programmatically navigate using react routerWhat is the difference between React Native and React?Enzyme test issues returns undefinedHow get value datapicker in react toobox custom?When I map over a populated array in this.state, why does it return undefined?
Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?
Meaning of "half-crown enclosure"
why "American-born", not "America-born"?
Make the `diff` command look only for differences from a specified range of lines
(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?
Is the default 512 byte physical sector size appropriate for SSD disks under Linux?
How to safely discharge oneself
What does it mean for something to be strictly less than epsilon for an arbitrary epsilon?
Is ideal gas incompressible?
One word for 'the thing that attracts me'?
Gas chromatography flame ionization detector (FID) - why hydrogen gas?
csname in newenviroment
Team member is vehemently against code formatting
Split into three!
Download app bundles from App Store to run on iOS Emulator on Mac
Is it normal to "extract a paper" from a master thesis?
VHDL: Why is it hard to desgin a floating point unit in hardware?
Caught with my phone during an exam
Three knights or knaves, three different hair colors
Does science define life as "beginning at conception"?
Adobe Illustrator: How can I change the profile of a dashed stroke?
nginx conf: http2 module not working in Chrome in ubuntu 18.04
Why is Ni[(PPh₃)₂Cl₂] tetrahedral?
Why is this python script running in background consuming 100 % CPU?
Problem Rendering an API on a Bootstrap Table with React
Loop inside React JSXReact “after render” code?Set focus on input after renderWhat is the difference between using constructor vs getInitialState in React / React Native?What do these three dots in React do?Programmatically navigate using react routerWhat is the difference between React Native and React?Enzyme test issues returns undefinedHow get value datapicker in react toobox custom?When I map over a populated array in this.state, why does it return undefined?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'am pretty new to React and i'm trying to render an API but it's creating new Table at every endpoint, the problem i think is because i'm mapping but i don't know what else to do.
Thanks in advance for the help.
Should i maybe create a new component for the Table
class App extends Component
constructor()
super();
this.state = ;
componentDidMount()
fetch(url)
.then(results =>
return results.json();
)
.then(data =>
let coins = data.map(coin =>
return(
<div>
<Table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
<tr>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
</tbody>
</Table>
</div>
)
);
this.setState( coins: coins );
);
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">this.state.coins</div>
</div>
);
reactjs api fetch
add a comment |
I'am pretty new to React and i'm trying to render an API but it's creating new Table at every endpoint, the problem i think is because i'm mapping but i don't know what else to do.
Thanks in advance for the help.
Should i maybe create a new component for the Table
class App extends Component
constructor()
super();
this.state = ;
componentDidMount()
fetch(url)
.then(results =>
return results.json();
)
.then(data =>
let coins = data.map(coin =>
return(
<div>
<Table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
<tr>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
</tbody>
</Table>
</div>
)
);
this.setState( coins: coins );
);
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">this.state.coins</div>
</div>
);
reactjs api fetch
add a comment |
I'am pretty new to React and i'm trying to render an API but it's creating new Table at every endpoint, the problem i think is because i'm mapping but i don't know what else to do.
Thanks in advance for the help.
Should i maybe create a new component for the Table
class App extends Component
constructor()
super();
this.state = ;
componentDidMount()
fetch(url)
.then(results =>
return results.json();
)
.then(data =>
let coins = data.map(coin =>
return(
<div>
<Table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
<tr>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
</tbody>
</Table>
</div>
)
);
this.setState( coins: coins );
);
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">this.state.coins</div>
</div>
);
reactjs api fetch
I'am pretty new to React and i'm trying to render an API but it's creating new Table at every endpoint, the problem i think is because i'm mapping but i don't know what else to do.
Thanks in advance for the help.
Should i maybe create a new component for the Table
class App extends Component
constructor()
super();
this.state = ;
componentDidMount()
fetch(url)
.then(results =>
return results.json();
)
.then(data =>
let coins = data.map(coin =>
return(
<div>
<Table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
<tr>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
</tbody>
</Table>
</div>
)
);
this.setState( coins: coins );
);
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">this.state.coins</div>
</div>
);
reactjs api fetch
reactjs api fetch
edited Mar 23 at 21:02
Yann
asked Mar 23 at 20:55
YannYann
376
376
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
is OK that you are very new to react, always try to read docs, especially on component life-cycle you don't seem to understand it. you might encounter some errors on the code because i don't know what your api is returning. but this is how your code should look like.
class App extends Component
constructor()
super();
this.state =
// i am asumming you are returning data
data : [];
;
componentDidMount()
fetch(url)
.then(results =>
//return results.json(); get the data from here and set it to state here. am assuming is called data
this.setState(
data:results.data
)
)
render()
let coins = this.state.data.map(coin => (
// i am assuming you have and id field else change it to any unique value
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
))
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
coins
</tbody>
</table>
</div>
</div>
)
add a comment |
Just want to add to Alcantara answer:
super()
is used for extending props from React libraryconstructor(props)
super(props);
this.state =
data : [];
;
You more often will see map function executed inside JSX (that what your problem was initially)
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
this.state.data.map(coin => (
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>))
</tbody>
</table>
</div>
</div>
)
I might be wrong for your particular case (I can't see what the data and styles all about), but more conventional way of displaying list of stuff is using
<ul></ul> <li></li>
tags
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318279%2fproblem-rendering-an-api-on-a-bootstrap-table-with-react%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
is OK that you are very new to react, always try to read docs, especially on component life-cycle you don't seem to understand it. you might encounter some errors on the code because i don't know what your api is returning. but this is how your code should look like.
class App extends Component
constructor()
super();
this.state =
// i am asumming you are returning data
data : [];
;
componentDidMount()
fetch(url)
.then(results =>
//return results.json(); get the data from here and set it to state here. am assuming is called data
this.setState(
data:results.data
)
)
render()
let coins = this.state.data.map(coin => (
// i am assuming you have and id field else change it to any unique value
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
))
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
coins
</tbody>
</table>
</div>
</div>
)
add a comment |
is OK that you are very new to react, always try to read docs, especially on component life-cycle you don't seem to understand it. you might encounter some errors on the code because i don't know what your api is returning. but this is how your code should look like.
class App extends Component
constructor()
super();
this.state =
// i am asumming you are returning data
data : [];
;
componentDidMount()
fetch(url)
.then(results =>
//return results.json(); get the data from here and set it to state here. am assuming is called data
this.setState(
data:results.data
)
)
render()
let coins = this.state.data.map(coin => (
// i am assuming you have and id field else change it to any unique value
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
))
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
coins
</tbody>
</table>
</div>
</div>
)
add a comment |
is OK that you are very new to react, always try to read docs, especially on component life-cycle you don't seem to understand it. you might encounter some errors on the code because i don't know what your api is returning. but this is how your code should look like.
class App extends Component
constructor()
super();
this.state =
// i am asumming you are returning data
data : [];
;
componentDidMount()
fetch(url)
.then(results =>
//return results.json(); get the data from here and set it to state here. am assuming is called data
this.setState(
data:results.data
)
)
render()
let coins = this.state.data.map(coin => (
// i am assuming you have and id field else change it to any unique value
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
))
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
coins
</tbody>
</table>
</div>
</div>
)
is OK that you are very new to react, always try to read docs, especially on component life-cycle you don't seem to understand it. you might encounter some errors on the code because i don't know what your api is returning. but this is how your code should look like.
class App extends Component
constructor()
super();
this.state =
// i am asumming you are returning data
data : [];
;
componentDidMount()
fetch(url)
.then(results =>
//return results.json(); get the data from here and set it to state here. am assuming is called data
this.setState(
data:results.data
)
)
render()
let coins = this.state.data.map(coin => (
// i am assuming you have and id field else change it to any unique value
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>
))
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
coins
</tbody>
</table>
</div>
</div>
)
answered Mar 23 at 21:28
AlcantaraAlcantara
526
526
add a comment |
add a comment |
Just want to add to Alcantara answer:
super()
is used for extending props from React libraryconstructor(props)
super(props);
this.state =
data : [];
;
You more often will see map function executed inside JSX (that what your problem was initially)
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
this.state.data.map(coin => (
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>))
</tbody>
</table>
</div>
</div>
)
I might be wrong for your particular case (I can't see what the data and styles all about), but more conventional way of displaying list of stuff is using
<ul></ul> <li></li>
tags
add a comment |
Just want to add to Alcantara answer:
super()
is used for extending props from React libraryconstructor(props)
super(props);
this.state =
data : [];
;
You more often will see map function executed inside JSX (that what your problem was initially)
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
this.state.data.map(coin => (
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>))
</tbody>
</table>
</div>
</div>
)
I might be wrong for your particular case (I can't see what the data and styles all about), but more conventional way of displaying list of stuff is using
<ul></ul> <li></li>
tags
add a comment |
Just want to add to Alcantara answer:
super()
is used for extending props from React libraryconstructor(props)
super(props);
this.state =
data : [];
;
You more often will see map function executed inside JSX (that what your problem was initially)
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
this.state.data.map(coin => (
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>))
</tbody>
</table>
</div>
</div>
)
I might be wrong for your particular case (I can't see what the data and styles all about), but more conventional way of displaying list of stuff is using
<ul></ul> <li></li>
tags
Just want to add to Alcantara answer:
super()
is used for extending props from React libraryconstructor(props)
super(props);
this.state =
data : [];
;
You more often will see map function executed inside JSX (that what your problem was initially)
render()
return (
<div className="container">
<HeadJumbotron />
<div className="container2">
<table striped bordered hover variant="dark">
<thead>
<tr>
<th>#</th>
<th>Sign</th>
<th>Name</th>
<th>Market Cap</th>
<th>Price</th>
<th>Change 24h</th>
<th>Buy</th>
</tr>
</thead>
<tbody>
this.state.data.map(coin => (
<tr key=coin.id>
<td>coin.market_cap_rank</td>
<td>coin.symbol</td>
<td>coin.name</td>
<td>coin.market_cap</td>
<td>coin.current_price</td>
<td>gerfds</td>
<td>@mdo</td>
</tr>))
</tbody>
</table>
</div>
</div>
)
I might be wrong for your particular case (I can't see what the data and styles all about), but more conventional way of displaying list of stuff is using
<ul></ul> <li></li>
tags
answered Mar 23 at 21:53
KevinKevin
4716
4716
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318279%2fproblem-rendering-an-api-on-a-bootstrap-table-with-react%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown