0
 render() {
    var NewsCards = this.state.news.map((b,i)=>{
        return(
            <div key={i} className="row">
                <div className="col-10">
                    <img src={b.image} className="img-fluid"/>
                </div>
            </div>
        )
    })
    return (
        <div className="container-fluid global-container-bottom-padding">
            {RenderIf(this.state.loading)(
            <div id="cssload-pgloading">
                <div className="cssload-loadingwrap">
                    <ul className="cssload-bokeh">
                        <li></li>
                        <li></li>
                        <li></li>
                        <li></li>
                    </ul>
                </div>
            </div>
            )}
            {RenderIf(!this.state.loading)(
                { NewsCards }
            )}
        </div>
    );
}

Not quite sure where I went wrong here.

EDIT:

this.state.news is an array of objects

[
    {
        "image":"imgurl",
        "link":"imglink"
    },
    {
        "image":"imgurl",
        "link":"imglink"
    }
]
2
  • What type of variable is news? Can you provide example structure? Commented Jun 6, 2017 at 9:40
  • I edited the post please see above Commented Jun 6, 2017 at 9:48

1 Answer 1

3

The issue is here, as you create an object literal with NewsCard field using object property shorthand syntax by mistake:

{RenderIf(!this.state.loading)(
  { NewsCards }
)}

Please change your code to:

!this.state.loading && 
<div>
  {NewsCards}
</div>

or

{RenderIf(!this.state.loading)(
  <div>{NewsCards}</div>
)}

as there is no support for fragments ready yet, at least before React 16.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.