Return jsx using the map function
I am new to react-redux
. Here what I am doing is ,
return analitics.map(analiticss => (
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
<div>
<span>
<i
className="fa fa-check-circle"
style={{ fontSize: "24px", color: "green" }}
/>
</span>
<span className="ml-2">
{analitics.wrong ? `${analitics.wrong}` : "0"}
</span>
</div>
<div>
<span>
<i
class="fa fa-times-circle"
style={{ fontSize: "24px", color: "red" }}
/>
</span>
<span className="ml-2">{analiticss.wrong}</span>
</div>
<div>
<span className="skip-background">
<i className="fa fa-fast-forward" style={{ color: "black" }} />
</span>
<span className="ml-2">{analiticss.skipped}</span>
</div>
<button type="button" className="btn btn-outline-primary">
Change
</button>
</div>
));
So, here I want to have this div on any condition. so what happens is ,
if the analiticss is not present then this will not get return. Because that there is no element to iterate.
so, I want to show that values as a `0.{analiticss.skipped} this values.
But it does not return this element as it does not have any array element.
One solution that I have is to use if else with expplicitely adding same html in this with 0 values.
But I don't think its a right solution. is there any onther solution that I can use ?
javascript reactjs redux react-redux
add a comment |
I am new to react-redux
. Here what I am doing is ,
return analitics.map(analiticss => (
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
<div>
<span>
<i
className="fa fa-check-circle"
style={{ fontSize: "24px", color: "green" }}
/>
</span>
<span className="ml-2">
{analitics.wrong ? `${analitics.wrong}` : "0"}
</span>
</div>
<div>
<span>
<i
class="fa fa-times-circle"
style={{ fontSize: "24px", color: "red" }}
/>
</span>
<span className="ml-2">{analiticss.wrong}</span>
</div>
<div>
<span className="skip-background">
<i className="fa fa-fast-forward" style={{ color: "black" }} />
</span>
<span className="ml-2">{analiticss.skipped}</span>
</div>
<button type="button" className="btn btn-outline-primary">
Change
</button>
</div>
));
So, here I want to have this div on any condition. so what happens is ,
if the analiticss is not present then this will not get return. Because that there is no element to iterate.
so, I want to show that values as a `0.{analiticss.skipped} this values.
But it does not return this element as it does not have any array element.
One solution that I have is to use if else with expplicitely adding same html in this with 0 values.
But I don't think its a right solution. is there any onther solution that I can use ?
javascript reactjs redux react-redux
add a comment |
I am new to react-redux
. Here what I am doing is ,
return analitics.map(analiticss => (
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
<div>
<span>
<i
className="fa fa-check-circle"
style={{ fontSize: "24px", color: "green" }}
/>
</span>
<span className="ml-2">
{analitics.wrong ? `${analitics.wrong}` : "0"}
</span>
</div>
<div>
<span>
<i
class="fa fa-times-circle"
style={{ fontSize: "24px", color: "red" }}
/>
</span>
<span className="ml-2">{analiticss.wrong}</span>
</div>
<div>
<span className="skip-background">
<i className="fa fa-fast-forward" style={{ color: "black" }} />
</span>
<span className="ml-2">{analiticss.skipped}</span>
</div>
<button type="button" className="btn btn-outline-primary">
Change
</button>
</div>
));
So, here I want to have this div on any condition. so what happens is ,
if the analiticss is not present then this will not get return. Because that there is no element to iterate.
so, I want to show that values as a `0.{analiticss.skipped} this values.
But it does not return this element as it does not have any array element.
One solution that I have is to use if else with expplicitely adding same html in this with 0 values.
But I don't think its a right solution. is there any onther solution that I can use ?
javascript reactjs redux react-redux
I am new to react-redux
. Here what I am doing is ,
return analitics.map(analiticss => (
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
<div>
<span>
<i
className="fa fa-check-circle"
style={{ fontSize: "24px", color: "green" }}
/>
</span>
<span className="ml-2">
{analitics.wrong ? `${analitics.wrong}` : "0"}
</span>
</div>
<div>
<span>
<i
class="fa fa-times-circle"
style={{ fontSize: "24px", color: "red" }}
/>
</span>
<span className="ml-2">{analiticss.wrong}</span>
</div>
<div>
<span className="skip-background">
<i className="fa fa-fast-forward" style={{ color: "black" }} />
</span>
<span className="ml-2">{analiticss.skipped}</span>
</div>
<button type="button" className="btn btn-outline-primary">
Change
</button>
</div>
));
So, here I want to have this div on any condition. so what happens is ,
if the analiticss is not present then this will not get return. Because that there is no element to iterate.
so, I want to show that values as a `0.{analiticss.skipped} this values.
But it does not return this element as it does not have any array element.
One solution that I have is to use if else with expplicitely adding same html in this with 0 values.
But I don't think its a right solution. is there any onther solution that I can use ?
javascript reactjs redux react-redux
javascript reactjs redux react-redux
edited Nov 20 '18 at 11:17


Tholle
34.1k53760
34.1k53760
asked Nov 20 '18 at 11:15


ganesh kaspateganesh kaspate
21119
21119
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If you want to still have the wrapper div visible, you need to move the map function inside of the wrapper div.
Something like:
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
{analytics.map(...)}
</div>
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
add a comment |
You can try this Sandbox Link.
I have added your code and there is no data inside the analytics.
https://codesandbox.io/s/zwr8391y24
Still you will see the Skipped
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
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%2f53391817%2freturn-jsx-using-the-map-function%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
If you want to still have the wrapper div visible, you need to move the map function inside of the wrapper div.
Something like:
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
{analytics.map(...)}
</div>
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
add a comment |
If you want to still have the wrapper div visible, you need to move the map function inside of the wrapper div.
Something like:
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
{analytics.map(...)}
</div>
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
add a comment |
If you want to still have the wrapper div visible, you need to move the map function inside of the wrapper div.
Something like:
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
{analytics.map(...)}
</div>
If you want to still have the wrapper div visible, you need to move the map function inside of the wrapper div.
Something like:
<div className="col-md-8 d-flex justify-content-around questionDetailRow1">
{analytics.map(...)}
</div>
answered Nov 20 '18 at 11:20


Gilad BarGilad Bar
643314
643314
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
add a comment |
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
Not wrapper div only, everything which is in the div
– ganesh kaspate
Nov 20 '18 at 11:25
add a comment |
You can try this Sandbox Link.
I have added your code and there is no data inside the analytics.
https://codesandbox.io/s/zwr8391y24
Still you will see the Skipped
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
add a comment |
You can try this Sandbox Link.
I have added your code and there is no data inside the analytics.
https://codesandbox.io/s/zwr8391y24
Still you will see the Skipped
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
add a comment |
You can try this Sandbox Link.
I have added your code and there is no data inside the analytics.
https://codesandbox.io/s/zwr8391y24
Still you will see the Skipped
You can try this Sandbox Link.
I have added your code and there is no data inside the analytics.
https://codesandbox.io/s/zwr8391y24
Still you will see the Skipped
answered Nov 20 '18 at 11:23


Harish SoniHarish Soni
859220
859220
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
add a comment |
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
I dont want to have just div, also want to have the data manipulation divs as well. but the values will get set to 0.
– ganesh kaspate
Nov 20 '18 at 11:29
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Which divs are for data manipulation?
– Harish Soni
Nov 20 '18 at 11:31
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
Did you tried the Sandbox link @ganeshkaspate???
– Harish Soni
Nov 20 '18 at 11:33
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%2f53391817%2freturn-jsx-using-the-map-function%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