flippyflops
Is there a way to enforce children of a particular component type?
I'm wanting to make a component that only accepts children that are a specific component so for example:
I tried playing around with
FlowProps
and FlowComponent
but couldn't quite get it to work. I think I'm pretty close but I'm not sure how I can allow passing the result of calling <Code /> while also enforcing the children are of type Code
.
So as a prop, items: (typeof Code)[]
for example allows me pass in Code
but not <Code />
.10 replies
Help with creating a builder pattern for main renderer
Wasn't sure how to fully articulate this but I want to have a class that lets me "build" the nested component structure that eventually gets passed into the
render
function.
I think I have it working with runtime behavior, but the type definitions aren't quite right and was hoping I could get some feedback on it.
Implementation
Usage
4 replies
Authenticated routes in SPA
I wanted to expose this question to more people and thought of this discord server.
Original post in GH:
https://github.com/solidjs/solid-router/discussions/364
The TL;DR; is that there doesn't seem to be a canonical approach to handling private vs public routes such that repetition is avoided -- I.E some type of middleware or guard.
I posted what I'm currently playing around with and will add it here for feedback, though in its current state it isn't working as expected. When using nested routes in the config-based approach this doesn't work.
7 replies
useContext from function dynamically imported
I'm building a keyboard shortcut management system and wanted to be able to dynamically import the action associated with a keybinding. Some of these keybindings may use a context so I've intentionally put the keyboard shortcut manager provider inside of all other providers.
action: () => import("../actions/switchColorScheme")
and in my index file:
I'm getting an error when trying to useContext()
in the action file's default function. Is that expected or is there a correct way of doing this? I thought that intentionally nesting the contexts where they'd normally work would be fine.54 replies
Testing createResource with dynamic import
I'm trying to test an
Icon
component that I built that uses a dynamic import inside of a createResource
. I attempted to mock createResource
but couldn't get it to work as expected... I'll just post a simplified version of the component in the hopes that someone knows based off of the code. And FWIW I'm using vite-plugin-solid-svg
to import svg files as solid components.
Also, I was prompted to try to do this because I can run tests to get 100% coverage on statements, branches, and lines... but my function coverage was like 3%. It seems to be related to the dynamic import so perhaps I'm barking up the wrong tree with createResource
?
2 replies
Reactivity in store
I think I may be missing the point of stores or just how to use them because I simply can't get it to trigger reactivity in a component. Below is a barebones example where I'm trying to have a value in a store and a function to update it - when the value changes I want to render it on the screen in a paragraph tag. Is there some obvious thing I'm missing here?
18 replies