mirror of
https://github.com/xtr-dev/payload-feature-flags.git
synced 2025-12-10 10:53:24 +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,
|
useConfig,
|
||||||
useTheme
|
useTheme
|
||||||
} from '@payloadcms/ui'
|
} from '@payloadcms/ui'
|
||||||
import { DefaultTemplate } from '@payloadcms/next/templates'
|
|
||||||
|
|
||||||
interface FeatureFlag {
|
interface FeatureFlag {
|
||||||
id: string
|
id: string
|
||||||
@@ -25,17 +24,10 @@ interface FeatureFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface FeatureFlagsViewProps {
|
interface FeatureFlagsViewProps {
|
||||||
i18n?: any
|
[key: string]: any
|
||||||
locale?: any
|
|
||||||
params?: any
|
|
||||||
payload?: any
|
|
||||||
permissions?: any
|
|
||||||
searchParams?: any
|
|
||||||
user?: any
|
|
||||||
visibleEntities?: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps) => {
|
const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => {
|
||||||
const { config } = useConfig()
|
const { config } = useConfig()
|
||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
const [flags, setFlags] = useState<FeatureFlag[]>([])
|
const [flags, setFlags] = useState<FeatureFlag[]>([])
|
||||||
@@ -623,20 +615,8 @@ const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps) => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
// Return the content directly - Payload handles the admin layout for custom views
|
||||||
<DefaultTemplate
|
return <FeatureFlagsContent />
|
||||||
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>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FeatureFlagsView = memo(FeatureFlagsViewComponent)
|
export const FeatureFlagsView = memo(FeatureFlagsViewComponent)
|
||||||
|
|||||||
Reference in New Issue
Block a user