Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
Explaining Generic Type

I have a problem understanding this interface

export interface StoryData<Content = StoryblokComponent<string> & { [index: string]: any }> {
  ...
  content: Content
  ...
}

This is the component type

export interface StoryblokComponent<TComp extends string> {
  _uid: string
  component: TComp
  _editable?: string
}

This is my dynamic component:

import { StoryData } from "storyblok-js-client";
import { components } from "../config/componentRegister";
export const DynamicComponent: React.FC<StoryData> = ({
  content,
}: StoryData) => {
  if (typeof components[content.component] !== "undefined") {
    const Component = components[content.component];

    return <Component content={content} />;
  }
  // fallback if the component doesn't exist
  return (
    <p>
      The component <strong>{content.component}</strong> has not been created
      yet.
    </p>
  );
};

My problem appears here:

export const Page: React.FC<StoryData> = ({
  content,
}: StoryData<StoryData>) => {
  let { grid } = content;
  return (
    <div {...sbEditable(content)}>
      {grid?.map((childContent) => (
        <DynamicComponent content={childContent} />
      ))}
    </div>
  );
};

Inside of content there can be more then just _uid: string component: TComp _editable?: string

There can be for exapmle size witch is an string. I can define the name of the key. It can also be an array of StoryData like grid: StoryData[] for example.

The error appears at the Props at my Page component

Type '({ content }: StoryData) => void' is not assignable to type 'FC<StoryData<StoryblokComponent<string> & { [index: string]: any; }>>'.
  Type 'void' is not assignable to type 'ReactElement<any, any>'.ts(2322)

How do i fix this error?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda