storyblok / storyblok-react

React SDK for Storyblok CMS
MIT License
122 stars 37 forks source link

resolve_relations not working with storyblok-react #20

Closed neil-morgan closed 2 years ago

neil-morgan commented 2 years ago

I'm getting a bug that seems to originate with storyblok-react

I am using resolve_relations and passing the same data to our "local" component and the storyblok editable component but when rendered in storyblok preview the data resolved by resolve_relations has been stripped out and only the uuid of the content is passed through.

Our components map.

import SbEditable from "storyblok-react";
import authorable from "./authorable/";
import template from "./template/";

const ComponentsList = {
  ...authorable,
  ...template
};

const Components = props => {
  if (typeof ComponentsList[props.component] !== "undefined") {
    const Component = ComponentsList[props.component];

    return (
      <SbEditable content={props} key={props._uid}>
        <Component content={props} key={props._uid}>
          {props.children}
        </Component>
      </SbEditable>
    );
  }

  return <p>The component {props.component} has not been created yet.</p>;
};

export default Components;

The image shows the resulting data difference when console logging the specific component I am using resolve_relations for. One version has the correct data, the other has had the resolve_relations data removed, returning only the uuid.

Screenshot 2021-12-02 at 15 44 05

Can anyone help guide me?

jromme commented 1 year ago

Would you care to share what fixed it for you? @neil-morgan The initial load appears to work for me, but when editing the data goes back to its uuid and thus giving errors.