0

I am trying to send data from one component to another when redirecting with react-router-dom's Link.

I have a list of Rooms that I render with a for loop. Those Rooms are wrapped in a Link like this:

<Link
  key={room.id}
  to={{
    pathname: `${room.id}`,
    state: {
      room: {room}
    }
  }}
>
  <Room room={room} />
</Link>

That Route corresponds to the ActiveChat component (the one that needs the data). However, when I do console.log(props); it returns an empty object (and props.location returns undefined)

The variable room is not empty (I also tried passing a string and returned undefined as well).

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
User
  • 53
  • 5

0 Answers0