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

sdk-react gen2 useContext #3044

Closed
woellij opened this issue Mar 5, 2024 · 7 comments · Fixed by #3197
Closed

sdk-react gen2 useContext #3044

woellij opened this issue Mar 5, 2024 · 7 comments · Fixed by #3197
Assignees

Comments

@woellij
Copy link

woellij commented Mar 5, 2024

Hi there, thanks for the great Product you're making here.

I'm trying to migrate a project from gen1 SDK to gen2 SDK but facing the issue that there is no documented way to access any BuilderContext like it was in gen1.

In Gen 1 i could access the BuilderStoreContext through react.useContext, which does not seem to be possible in gen2.

I've looked through the compiled sources and exported types and there does not seem to be a way.

Is this on the roadmap to add / document?

Thanks in advance.

@woellij
Copy link
Author

woellij commented Apr 4, 2024

Hi. Just following up. We'd like to use the GEN2 SDKs but there is no way to update the BuilderStoreContext with a new state. Could you enlighten us please?

@mrkoreye
Copy link
Collaborator

mrkoreye commented Apr 4, 2024

Hi @woellij , can you describe what you are trying to achieve in more detail so that we can help? As in, what is the end goal you have? Are you trying to pass functions to be used within Builder content? Set an initial state for Builder content?

@woellij
Copy link
Author

woellij commented Apr 4, 2024

Hi @mrkoreye ,
The Goal is to Update the state from a custom component.
Im our case there is a custom component in which the User can select a product which should cause an update to the state, so text on the page can bind to the product's properties.
We have other uses for the state and context (passing state and context props to child components)

@samijaber
Copy link
Contributor

@woellij Thanks for reporting. The context exists but is not currently being exported by the Gen2 SDKs.

I will let you know here when it is fixed.

@samijaber samijaber assigned samijaber and unassigned mrkoreye Apr 5, 2024
samijaber pushed a commit that referenced this issue Apr 15, 2024
## Description

This PR exports `BuilderContext` as a named export in our gen2 sdks.

_Screenshot_
If relevant, add a screenshot or two of the changes you made.

**Jira**
https://builder-io.atlassian.net/browse/ENG-5614

Closes #3044
@samijaber
Copy link
Contributor

@woellij
Copy link
Author

woellij commented Apr 16, 2024

Thanks, I will check it out

@woellij
Copy link
Author

woellij commented Apr 17, 2024

Hi.
I had a look and while i can reference the BuilderContext in useContext, there is no real typescript type information and one would have to resort to the builder.io sourcecode to find out about BuilderContextInterface.
In my opinion that's not really optimal.

Also, the text does not update when the rootState is updated with rootSetState. Is there a way to accomplish that from a custom Component? If the state is set through an Action configured in builder.io the text updates.

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

Successfully merging a pull request may close this issue.

3 participants