Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!