jesseb34r
Explore posts from serversConfused by context updating in handleOnMouseDown()
I can share more code if needed but the component is pretty large and I don't think all the context is needed for this. I have a component for a drag and drop canvas that when clicked should set the starting mouse position and then calculates it's position based on the difference between the current mouse position and the starting mouse position. The problem is that the starting mouse position gets set multiple times even though I only want it set once. Does anyone know why this is happening?
50 replies
how to add function call into JSX
I have a component setup like
where
GameRoot
is a context provider that sets up a game state and stores a list of card ids for each zone. For testing purposes I want to load some initial cards into the state. Can I put a function call to my setState
function in the JSX? I've tried a couple things that felt intuitive to me but am not figuring it out. I could pass some initial state into the GameRoot component with props but that isn't how I want to implement it in the end so I would rather not5 replies
Redirect to current location from createServerAction$()
I have a logout action that I would like to logout the user without changing the location. My current code looks like this:
This code is functional but it redirects to the home page of my app. I can't use
useLocation()
in a server action, so is there a way to do this without redirecting to the home page?7 replies
When is `keyed` useful for `<Show />`
The docs don't have a great explanation. My best understanding is that it allows you to use the value that the Show depends on in the rendering of the show but every time i've used a show it's been with a signal. Should I be using the keyed pattern or just reuse the signal?
Example:
55 replies
Does mergeProps deep merge objects?
I have a syntax on my components where I define styles with an
atoms
prop like <MyComponent atoms={{*some styles}} />
. As I am building out by components, I want to be able to set base styles with this prop but also allow the consumer of the component to define an atoms prop and have it merge with the base styles. I'm currently using lodash merge for this but was wondering if the mergeProps
function could help here.
Current Method: (<Text />
takes the atoms prop)
Cleaner method that I am unsure if works:
3 replies
How does height of the body work in Solid Playground?
This may just be a lack of understanding of CSS but in my defense, CSS is hard. Here is the link to the component I'm prototyping in the playground: https://playground.solidjs.com/anonymous/962a237f-cfbd-4a77-bc7f-f2034bdbd5fa.
What I'm wondering is why my
Open Modal
button is centered on the height of the window without considering the console whereas the actual modal is centered in the viewable space accounting for the console. The button is centered in a flexc container with a height of 100vh
whereas the modal is centered with position: absolute, top: '50%', left: '50%', transform: 'translate(-50%, -50%)'
.
Is this a specific behavior of the solid playground or is this a CSS specific thing with heights that I don't understand?6 replies
function MyComponent() vs arrow function Component
I am relatively new to the design space of component systems and figuring it all out. I still don't understand the tradeoffs and standards for why to use different syntaxes for declaring components. Basically, what is the best way or what are the tradeoffs between defining components in these different ways?
10 replies
Is `style={}` performant?
I am using Vanilla Extract's Sprinkles API in my project to get static performance and a css-in-js feel but I can't put every style I need in a utility class. For instance sometimes I want to define a specific grid layout or gradient background. As far as I can tell my best options are using a style tag inline in the element which puts the css rules all together or to use vanilla extract's css modules which defines those specific styles in a separate file. What I don't know is the difference in performance between them. I know that in html the style tag is seen as not performant, is Solid different?
Example with style tags: (I like this but don't know about performance)
Example with modules: (what I'm doing now but it's a bit clunky and I'd like to use the css in js patterns)
10 replies