Skip to content

Commit

Permalink
fix: initial context
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum committed Nov 2, 2022
1 parent c0f3d2d commit e253cc8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@ interface Props {
children: React.ReactNode;
}

const initialContext = {};
const initialContext = Emm.getManagedConfig<unknown>();
const Context = createContext<any>(initialContext);

export function useManagedConfig<T>(): T {
return useContext<T>(Context);
}

export const Provider = ({ children }: Props) => {
const [managed, setManaged] = useState<unknown>(initialContext);

useEffect(() => {
const config = Emm.getManagedConfig<unknown>();
setManaged(config);
}, []);
const [managed, setManaged] = useState<unknown>(Emm.getManagedConfig());

useEffect(() => {
const listener = Emm.addListener((config: unknown) => {
Expand Down

0 comments on commit e253cc8

Please sign in to comment.