Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems loading <open-stories> and Next.js #10

Closed
JamesIves opened this issue Aug 8, 2023 · 1 comment
Closed

Problems loading <open-stories> and Next.js #10

JamesIves opened this issue Aug 8, 2023 · 1 comment

Comments

@JamesIves
Copy link

JamesIves commented Aug 8, 2023

I'm attempting to load the <open-stories> custom element with Next.js and I seem to be running into a few issues, primarily this is the error I'm getting that is preventing the element from displaying:

TypeError: Cannot set property src of #<OpenStoriesElement> which has only a getter

I'm loading the component client-side like so within a wrapper React component;

'use client'

export default function Stories() {
  return <open-stories src="/api/screenshots"></open-stories>
}

The endpoint resolves to a valid schema, when requested in the browser you get the following:

{"version":"https://jsonfeed.org/version/1.1","title":"Screenshots","_open_stories":{"version":"0.0.9"},"items":[{"id":"2605764403","content_text":"","authors":[{"name":"James","url":"https://jives.dev"}],"_open_stories":{"mime_type":"image/jpg","url":"https://steamuserimages-a.akamaihd.net/ugc/1635359675946958706/E517E16CA053E10ED3EED88E0083F157EBF860E6/","alt":""}}]}

I'm unsure if this error is directly related to Next.js or not. When I exclude the src property from the web component it loads correctly, and you can see the Shadow DOM mount. 🤔

Any help would be super appreciated!

@JamesIves JamesIves changed the title Problems with <open-stories> and Next.js Problems loading <open-stories> and Next.js Aug 8, 2023
@JamesIves
Copy link
Author

JamesIves commented Aug 8, 2023

Ah! Figured out my issue right after posting this. The src needs to be relative;

'use client'

export default function Stories() {
  return <open-stories src="./api/screenshots"></open-stories>
}

Edit: Ah turns out this is not strictly the case. Opened dddddddddzzzz/open-stories-element#14 with a potential fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant