Is there any way to use global context data in Plasmic Studio?

Hi, the forum has been going down for a couple of days, do you know when the issue will be resolved? Thanks

Also, I would like to ask if there is any way to use Global Context data (created as Code Component) in the studio? There is fair bit of global data I want to be able to use across multiple components. Cheers

For example, I created a UserContextProvider with data like username, age. How do I render the username as Plasmic Text’s content prop?

Hi @parental_bobolink, thanks for raising - we’re looking into it

Should be back

thanks a lot

You can do this using the dataprovider component, let me know if that helps: https://docs.plasmic.app/learn/data-code-components/

This means I would have to use Code Component instead?

Oh I thought that’s what you were asking about, how to create a global context provider that provides some data that can be used in the studio

Global context providers are just react components https://docs.plasmic.app/learn/global-contexts/

So you can inside of that react components render a dataprovider that provides any data to your plasmic project

Then from within plasmic studio, you can right-click the content setting of a text element and use a dynamic value there, picking the data you provided

thanks Yang for your answer. I understand I can access the global context data through code component, however my question is: is it possible to access global context without creating extra code component

You don’t need a code component to access global context, just right click

oooh, that’s something I don’t know. Can you advise me more

let say I have created a React Global Context code component like

export default function ClientContextProvider(props: React.PropsWithChildren<ClientContextProps>) {
    const {
        logoUrl,
        tagline,
        children,
    } = props;

    return (
        <ClientContext.Provider value={{ logoUrl, tagline, }}>
            {children}
        </ClientContext.Provider>
    );
}

Then in the project settings, i have setup the logoUrl and tagline I want

Are you missing the dataprovider there?

Right, so we need to add Data Provider into it

Yes

that’s quite interesting, I can create a Custom behavior component for this then. I think I get it now :slightly_smiling_face:

thanks a lot, Yang

No problem, and just to clarify, you shouldn’t need custom behavior code components to access the data provided by a dataprovider, you can just right click and use dynamic value