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

Fix live editing with RSC #1309

Open
1 task done
brightonmike opened this issue Jan 6, 2025 · 1 comment
Open
1 task done

Fix live editing with RSC #1309

brightonmike opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels
pending-author [Issue] Awaiting further information or action from the issue author

Comments

@brightonmike
Copy link

Describe the issue you're facing

I couldn't get live editing to work. Content edits are only showing up when you save a page.

I followed this page: https://github.com/storyblok/storyblok-react?tab=readme-ov-file#nextjs-using-app-router
The only difference is I am using custom GraphQL data fetching.

I've found the code that prevents this from working & when I make a couple of small adjustments locally, it all seems to work fine. So far, I'm not seeing any issues or side effects with the edits I've made. For now I've applied them locally via a patch.

Here I remove this check for the window object: https://github.com/storyblok/storyblok-react/blob/main/src/rsc/live-editing.tsx#L8

When bundled, this code stops working: https://github.com/storyblok/storyblok-react/blob/main/src/rsc/live-edit-update-action.ts#L11

The set method and runtime check are combined into a single if statement e.g.
if (globalThis.storyCache.set(e.uuid, e), process.env.NEXT_RUNTIME)
The set method then does not fire, however if I manually move it outside the if statement it's all working correctly.

I can look to put together a reproduction, however, this issue is only occurring within Storyblok when using the bridge.

Both fixes here feel a little strange. I can't quite figure out yet why my changes fix live editing - but they do.

Reproduction

na

Steps to reproduce

No response

System Info

"@storyblok/react": "4.0.0"
"next": "15.0.3"
"react": "19.0.0-rc-66855b96-20241106"

Used Package Manager

yarn

Error logs (Optional)

No response

Validations

@brightonmike brightonmike added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Jan 6, 2025
@edodusi edodusi removed the pending-triage [Issue] Ticket is pending to be prioritised label Jan 7, 2025
@edodusi edodusi self-assigned this Jan 7, 2025
@edodusi
Copy link
Contributor

edodusi commented Jan 7, 2025

Thanks for reporting @brightonmike. ATM the SDK and JS Client are only officially supporting using the Client's exposed APIs (get, getStory, ...) and not custom fetch or GraphQL.

However, I would like to be able to fully and officially support them, like within the scenario you described here.

I cannot guarantee I will be able to prioritize this, but if you could submit a PR this may be a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author
Projects
None yet
Development

No branches or pull requests

2 participants