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.

(Payload Beta) CollectionConfig doesn't accept React.FC anymore?

default discord avatar
evil.dykelast year
10

Hello, while troubleshooting I found [this old article](

https://payloadcms.com/blog/building-a-custom-field

) that is no longer relevant but shows what I believe should be happening.



For objects of type Field you can specify an admin attribute and then a custom component (see screenshot). Based on the article it looks like React components were previously allowed but now I have trouble finding any documentation on what the alternative type should be. Digging into the code wasn't super helpful to me 😦 any ideas?

  • default discord avatar
    notchrlast year

    RenderSubmissionAsForm is a tsx file?

  • default discord avatar
    evil.dykelast year
    @1049775120559898725

    yes 🙂

  • default discord avatar
    notchrlast year

    Can you post the component here



    Also, to confirm, this is v2 or v3?



    This is the base example for a custom field component



    import { useField } from 'payload/components/forms'
    
    const CustomTextField: React.FC<{ path: string }> = ({ path }) => {
      const { value, setValue } = useField<string>({ path })
    
    
      return <input onChange={(e) => setValue(e.target.value)} value={value} />
    }
  • default discord avatar
    evil.dykelast year

    This is v3

  • default discord avatar
    notchrlast year

    So this is a client component or server component?

  • default discord avatar
    evil.dykelast year

    Even if I copy + paste that component the same type error appears 🤔

  • default discord avatar
    notchrlast year

    How about



    'use client' 
    import React, { useState } from 'react'
    
    export const MyClientComponent: React.FC = () => {
      const [count, setCount] = useState(0)
    
      return (
        <button onClick={() => setCount(count + 1)}>
          Clicked {count} times
        </button>
      )
    }
  • default discord avatar
    anders2292last year
    @310897398409068544

    Take a look at the release notes for v3 beta 79. How you include custom components has changed.



    https://github.com/payloadcms/payload/releases/tag/v3.0.0-beta.79
  • default discord avatar
    notchrlast year

    Nice find

    @1063099015589273630
  • default discord avatar
    evil.dykelast year

    Thank you both 🙂

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.