mirror of
https://github.com/xtr-dev/payload-feature-flags.git
synced 2025-12-10 02:43:25 +00:00
Fix runtime error: payload undefined in custom view
Runtime Fix: - Removed DefaultTemplate wrapper that was causing payload undefined error - Simplified component to return content directly for Payload custom views - Payload CMS automatically provides admin layout for custom views - Removed unnecessary template prop dependencies Component Structure: - Custom views in Payload are rendered within the admin layout automatically - No need for manual DefaultTemplate wrapper in custom view components - Maintained all spreadsheet functionality and theme integration - Simplified props interface to handle any view context The feature flags view now renders correctly as a Payload custom view without runtime errors, while preserving all functionality and admin layout. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
||||
useConfig,
|
||||
useTheme
|
||||
} from '@payloadcms/ui'
|
||||
import { DefaultTemplate } from '@payloadcms/next/templates'
|
||||
|
||||
interface FeatureFlag {
|
||||
id: string
|
||||
@@ -25,17 +24,10 @@ interface FeatureFlag {
|
||||
}
|
||||
|
||||
interface FeatureFlagsViewProps {
|
||||
i18n?: any
|
||||
locale?: any
|
||||
params?: any
|
||||
payload?: any
|
||||
permissions?: any
|
||||
searchParams?: any
|
||||
user?: any
|
||||
visibleEntities?: any
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps) => {
|
||||
const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => {
|
||||
const { config } = useConfig()
|
||||
const { theme } = useTheme()
|
||||
const [flags, setFlags] = useState<FeatureFlag[]>([])
|
||||
@@ -623,20 +615,8 @@ const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps) => {
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<DefaultTemplate
|
||||
i18n={props.i18n}
|
||||
locale={props.locale}
|
||||
params={props.params}
|
||||
payload={props.payload}
|
||||
permissions={props.permissions}
|
||||
searchParams={props.searchParams}
|
||||
user={props.user}
|
||||
visibleEntities={props.visibleEntities}
|
||||
>
|
||||
<FeatureFlagsContent />
|
||||
</DefaultTemplate>
|
||||
)
|
||||
// Return the content directly - Payload handles the admin layout for custom views
|
||||
return <FeatureFlagsContent />
|
||||
}
|
||||
|
||||
export const FeatureFlagsView = memo(FeatureFlagsViewComponent)
|
||||
|
||||
Reference in New Issue
Block a user