Skip to content
Gx
GitHub

GX4014: shared signal in a component with no gx.Room prop

A signal with the word shared needs a room, and the component has no prop of type gx.Room for the key of the room.

Cause

A shared signal has one value for each viewer of a room. The key of the room is a server value. A loader makes it with gx.RoomKey and gives it to the component as a prop of type gx.Room.

A component with a shared signal and no such prop has no room.

Example

notes/Note.gx
package notes

signals {
  shared Typing bool = false
}

<p show={$Typing}>A viewer writes</p>

gx check reports:

gx check
notes/Note.gx:4:3: GX4014: the shared signal "Typing" needs a room: the component has no prop of type gx.Room

Fix

  1. Add the prop to the component: props { Room gx.Room }.
  2. In the loader of the page, make the key: gx.RoomKey(c, "doc-42"). Give it to the component: <Note room={p.Room} />.
  3. For a value that only one viewer sees, remove the word shared.