boyjarv
6 months ago
1019
6
Laravel

Loop through $users in React

Posted 6 months ago by boyjarv

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

Please sign in or create an account to participate in this conversation.