Render Object properties in React

javascript, object, reactjs

Solution

You are rendering an array but you can only return a single block from your react component, wrap your map function within a div

class Information extends Component {
    render() {
        const otherInformationLoop = otherInformation.map((value, key) => {
            return (
                <div>
                    <div className="col-md-4" key={key}>
                        <div className="dashboard-info">

                            {Object.keys(value).map((val, k) => {
                                return (<h4 k={k}>{val}</h4>)
                                })
                            }

                        </div>
                    </div>
                </div>
            )
        })

        return (

            <div>{ otherInformationLoop }</div>
        );
    }
}

Problem

I have a object like this ``` export const otherInformation = [ { "FAQ": ['Getting started guide', 'Selling policy'], "Help & Support": ['Help guide', 'Selling policy'], "Legal": ['Terms of Use', 'Privacy Policy'] }] ``` My code ``` class Information extends Component { render() { const otherInformationLoop = otherInformation.map((value, key) => { return ( <div> <div className="col-md-4" key={key}> <div className="dashboard-info"> {Object.keys(value).map((val, k) => { return (<h4 k={k}>{val}</h4>) }) } </div> </div> </div> ) }) return ( { otherInformationLoop } // <div></div> ); } } ``` Im having trouble looping through the object. Error obtained is like this `Information.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object` How can I loop thorugh the object so that the obtained result is obtained Thanks in advance. Any help is appreciated

Original source