Skip to content

Changing the config dynamically doesn't apply the new config #1450

Open
@endrits079

Description

@endrits079

Description

If the config is changing it is not reflecting on the components.

CodeSandbox/Snack link

No response

Steps to reproduce

  1. Create 2 configs.

  2. Have a state to decide which config to use

  3. Based on the state provide a config object:
    function ThemedApp({children}: {children: React.ReactNode}): JSX.Element {
    const [config, setConfig] = useState("blue")
    const themeConfig = useMemo(
    () => config === "blue" ? blueConfig : greenConfig ,
    [config],
    );
    return (

    {children}

    );
    }

  4. Have a button that changes the state (for example between green and blue ) if the green config has primary color as green and blue config primary color as blue then it is not applying it is stuck on initial ( which is blue in this case )

gluestack-ui Version

1.0.17

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

A simple code example:

import {Button} from "@gluestack-ui/themed"
import {blueConfig, greenConfig} from "./config"

function ThemedApp({children}: {children: React.ReactNode}): JSX.Element {
  const [config, setConfig] = useState("blue")
  const themeConfig = useMemo(
    () => config === "blue" ? blueConfig : greenConfig ,
    [config],
  );
  return (
    <GluestackUIProvider config={themeConfig} colorMode="light">
      {children}
     <Button onPress={()=>{
        setConfig(prev=>prev==="blue" ? "green" : "blue")
     }}>Change config</Button>
    </GluestackUIProvider>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggluestack-styleIssue related to gluestack-style

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions