I think I need to pass my variable through as a json object so I can loop through it using .map()
How can I pass my variable through as a JSON object into the react file?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
At the moment, I have set an array [1,2,3,4] as you can see below:
{[1,2,3,4].map((userId) => {
return this.user.id !== userId ? <button key={userId} onClick={() => this.callTo(userId)}>Call {userId} </button> : null;
})}
I am passing $users through from my Laravel app, I would like to know how to loop through $users and pull the ID and Name into react?
Thanks
I have now sorted it with help form this video: https://www.youtube.com/watch?v=N5vIFKXhNpc&list=PLS28RXxLK_RRh5y0vwkL2CFVpyjwd_oyy&index=11
Please or to participate in this conversation.