poll() discards mount data

Appears that adding poll() to the table causes the the $record in mount to become null after about 2s. The table rows are shown then after about 2s it throws an error. Attempt to read property "id" on null
At first I thought it was the Poll nterval but then changed it to a longer value and the error still happens after 2s. When both the ->where('campaign_contact_id', $this->record->id ) and poll(2) there is an error. Without one or the other, no error
class ViewContact extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;

protected ?Model $record = null;

public function mount ($record = null) {
$this->record = $record;
// dd($this->record) shows the data;
}

public function table(Table $table): Table
{
return $table
->poll(6)
->query(
Conversation::query()
// error on line below
->where('campaign_contact_id', $this->record->id )
)
->columns([
TextColumn::make('name'),
]);
}

public function render(): View
{
return view('livewire.view-contact');
}
}
class ViewContact extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;

protected ?Model $record = null;

public function mount ($record = null) {
$this->record = $record;
// dd($this->record) shows the data;
}

public function table(Table $table): Table
{
return $table
->poll(6)
->query(
Conversation::query()
// error on line below
->where('campaign_contact_id', $this->record->id )
)
->columns([
TextColumn::make('name'),
]);
}

public function render(): View
{
return view('livewire.view-contact');
}
}
2 Replies
ddoddsr
ddoddsrOP2w ago
YES! added InteractsWithRecord and removed protected ?Model $record = null; thanks much. Why I left Nova forever!
Want results from more Discord servers?
Add your server