Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How to pass a fields data into the custom cell component

default discord avatar
lildeliri0us5 months ago
1

Hi there, I'm struggling with the latest beta version

("v3.0.0-beta.123")

of payload when trying to implement a

custom cell component

, for my

collections Listview.

I have red the docs

both beta and the latest Payload version,

gone through

GitHub issues,

asked *ChatGpt * and now read through the discord channel. I am at a loss.



'use client'; import classNames from 'classnames'; import {FC} from 'react'; export const StatusCell: FC = (props) => { console.log(props); return ( <div className={classNames({ 'status-label-pending': 'pending' === 'pending', //the comparison is just a placeholder so I could test my component of even being rendered (it is being rendered) 'status-label-recorded': 'recorded' === 'recorded', 'status-label-action': 'actionRequired' === 'actionRequired', })}></div> ); };

This is my custom cell component, when logging the props via console it displays

none of the actual props

listed in the docs of either beta & latest version of Payload. I do however get the correct field (

type select

) that I have assigned the cell component to, but only it’s config, where I have no access to the actual value it saved.



When I however try to use the Server Version of the cell component I get a

whole lot more - still no value,

but of course I cannot use helpful hooks to somehow get the value of my field differently as a workaround.




I have tried using useField, but here I am also at a loss because it does not work the way the beta docs describe and to use it the way the latest payload docs use it, I would also need the props in the non-beta version of a cell component to make it work.


__



I just need a somewhat correct docs, example or link to either, of a simple custom cell component able to display its corresponding fields data - using the beta version 3.0.0-beta.123.



Any information, help & support would be greatly appreciated!

:CryCat:

🙏



Thank you for the quick message! Unfortunately that would not quite be what I'm searching for, since I am only trying to edit a single cell for a collections overview of entries - and by typing it to an actual Field i would not actually get a Cell component? (Do correct me if I understood incorrectly...)

  • default discord avatar
    zed05475 months ago

    Instead of typing your component with FC, you can use

    TextFieldClientComponent

    exported from Payload and the props of your comp will populate automatically with a variable named

    data

    that had what you're looking for I believe. There's also other useful props passed to it by Payload:

    https://payloadcms.com/docs/beta/admin/fields#default-props
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.