Ah ok so because I was trying to render it in the functional component that is why it was throwing the error with the objects array?
Not really, passing functions also work: codesandbox.io/s/twilight-frog-462...
Post your whole code for reference ;)
Ah ok so does it matter which way you approach? Is there such a thing as best practice in React?
import React from 'react' let arrayMethods = [ // array of objects here ] let methodsList = arrayMethods.map((method) => <li className="list-group-item" key={method.name}> <strong>{method.name}</strong> {method.method}</li> ) const Methods = () => { return ( <div className="row"> <div className="col-12 text-center"> <input className="mb-3 p-2 align-center rounded" type="text" placeholder="Search for a method" /> <form className="col-12 text-center"> <input className="mb-3 p-2 rounded" id="methodname" placeholder="Method name" type="text" /> <input className="p-2 rounded" id="method" placeholder="Enter method" type="text" /> <input className="p-2 rounded" id="example" placeholder="Enter example" type="text" /> <button className="btn btn-success" type="button">Add Method</button> <br /> </form> </div> <div className="col-6"> <ul className="list-group bg-danger"> {methodsList} </ul> </div> {/* Textbox to show examples using methods */} <div className="col-6 pl-0"> <textarea className="bg-dark col pt-3 text-white" name="exampleBox" id="exampleBox" rows="20" ></textarea> </div> </div> ) } export default Methods
Yes, using components is preferable. Your code renders fine: codesandbox.io/s/magical-smoke-gz6...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ah ok so because I was trying to render it in the functional component that is why it was throwing the error with the objects array?
Not really, passing functions also work: codesandbox.io/s/twilight-frog-462...
Post your whole code for reference ;)
Ah ok so does it matter which way you approach? Is there such a thing as best practice in React?
Yes, using components is preferable. Your code renders fine: codesandbox.io/s/magical-smoke-gz6...