SolidJSS
SolidJSβ€’3y agoβ€’
4 replies
TheOinkinator

Createeffect not working in component where signal was defined

I am pretty new to programming so it is possible I have some kind of oversite. but in this code:

import FMHome from "./FMHome";
import FMSearch from "./FMSearch";
import FMBookmark from "./FMBookmark";
import FMAccount from "./FMAccount";
import "./floatingMenuStyles/fmStyle.css";
import "./floatingMenuStyles/fmItemStyle.css";
import { createEffect, createSignal } from "solid-js";

type MenuStates =
  | "allClosed"
  | "homeOpen"
  | "searchOpen"
  | "bookmarkOpen"
  | "loading";

export const [menuState, setMenuState] = createSignal<MenuStates>("homeOpen");

export default function FloatingMenu() {
  createEffect(() => {
    console.log(menuState());
  });
  return (
    <>
      <div class="floatingMenuContainer">
        <FMHome />
        <FMSearch />
        <FMBookmark />
        <FMAccount />
      </div>
    </>
  );
}

the createEffect to log menuState will not work in a child component FMSearch:
Was this page helpful?