I have been working on developing a scene switcher for my personal application, and I thought of creating a custom component called SceneSwitcher
. Inside this component, I plan to add various scenes that can be rendered. Here's an example:
<SceneSwitcher>
<LoadingScene />
<AppScene />
<LoginScene />
</SceneSwitcher>
SceneSwitcher.tsx
export default function SceneSwitcher() {
const [scene, setScene] = createSignal("");
...
return (
<>
{props.children.find(e => e.id === scene()) ?? <div></div>}
</>
);
}
However, I'm facing an issue where props.children.find
always returns undefined
, even when the value of scene()
matches one of the IDs.
IDs on Scenes: LoadingScene.tsx
export default function LoadingScene() {
...
return (
<div id="loading">
<h1>Loading content...</h1>
</div>
);
}
Just a few days ago, I started exploring component-style frameworks, although I have experience in programming websites using vanilla JavaScript for 4 years. This project is an opportunity for me to delve deeper into component-style frameworks and explore different approaches to problem-solving.