SolidJS
Solid is a declarative reactive Javascript library for creating user interfaces.
Join ServerCommunity questions
Channels
How can i go back with @solidjs/router package ?
What are the differences? Produce vs regular setStore
Question:
Besides produce allowing to neatly update specific properties of an object, are there any other differences? Any performance nuances between these 2 approaches dealing with stores?
```js
import { createStore, produce } from "solid-js/store";
export function SolidComponent() {
const [solidStore, setSolidStore] = createStore({ a: "aaa", b: "bbb" });
function updateA() {
console.log("A");
setSolidStore((obj) => {
ret...
How to create an effect that runs on page navigate
Integrate External, Read-Only Data Source Into Reactive System
```tsx
// Hypothetical external data
let externalData = new Map()
EventEmitter.emit("dataChanged", /no event info/)
// My problem...
function externMemo (externData) {
EventEmitter.on("dataChanged", ()=>/trigger getter refetch & dom update/ )
let getter = ()=>{
// ...
return externData
}
return getter
}
// Hypothetical Component
let component = () => {
let reactiveData = externMemo(externalData)
return (
<div>...
vite bundling unused components from external libraries (SSR)
render
function is too big. is there anything i can do to make it exclude icons i am not using?How to mutate a createResource storage
```javascript
function createDeepSignal<T>(value: T): Signal<T> {
const [store, setStore] = createStore({
value
});
return [
() => store.value,
(v: T) => {
const unwrapped = unwrap(store.value);
typeof v === "function" && (v = v(unwrapped));
setStore("value", reconcile(v));
return store.value;
}
] as Signal<T>;
}
const [resource, {mutate, refetch}] =...
Are there any important considerations to creating signals in control component callbacks like For
<For each={props.data}>
{(data) => {
const [isOpen, setOpen] = createSignal(false);
return <Component data={data} isOpen={isOpen} onClick={()=>setOpen(x=>!x)}/>;
}}
</For>
Or if it's actually better to have some intermediary component where the signal to track state is declared in jsx.
Thanks
Dispose function not actually disposing of anything
Failed to execute 'querySelector' on 'Document': '#' is not a valid selector.
React key prop substitute!
Cheers,
James
Best way to dynamically access i18n-translations with typescript
I am currently using @solid-primitives/i18n (https://github.com/solidjs-community/solid-primitives/tree/main/packages/i18n#readme) for translation purposes.
However there's one thing i struggle with:
Some of the keys I would like to access are coming from an api, where each key is typed as generic string.
For example imagine that my dict looks like this:
const en_dict = {
foo: {
bar: 'Bar',
baz: 'Baz'
}
}
And I want to translate like this:
```tsx
const...
i18n and context issues
I am currently migrating to the 2.0.0 release of
@solid-primitives/i18n
. (https://github.com/solidjs-community/solid-primitives/tree/main/packages/i18n#readme)However I have a few questions:
1. The way
t
is being defined in the docs will always give me the famous reactive variable 'xxx' should be used within JSX
error. Which makes sense. Therefore I wonder, why all examples are build this way even though locales and therefore the current dict might change? Is this an error...Difference between `setState` and `produce`?
appState
as a store, and I'm trying to pass appState.selectedTable
as a prop to a child component. When I simply use setAppState
, it doesn't trigger a prop change in the child component. I've found that I need to use produce
for it to work. The problem is, the documentation only gives a one-liner about the produce
API. Could someone provide more information on how to properly use produce
and createStore
in this context?Solid Start not deploying on vercel in turborepo
my solid start project doesn't deploy to vercel, aka every build fails.
There are no error's though, the build fails, because the deployment duration takes over 45 minutes.
There are 0 errors in the output log, and the output ends with the following
backend:build: solid-start build
backend:build: version 0.2.32
backend:build: adapter vercel
backend:build:
backend:build: solid-start building client...
backend:build: solid-start rendering index.html...
Problem duplicating a component navigating with dynamic routing
Example route def:
<Route path="/search" component={Search}>
<Route path="/" />
<Route path="/:id" component={SearchWorkspace} />
</Route>
My intention is to navigate between say
/search/123456789
to /search/987654321
but am unable to get the components to re-render unless I visit another route first. The `Searc...
How to solve ts(2322) error on "each" attribute of "For" component
```
Type '(() => Promise<any>) | undefined' is not assignable to type 'false | readonly any[] | null | undefined'.
Type '() => Promise<any>' is not assignable to type 'false | readonly any[] | null | undefined'.ts(2322)
flow.d.ts(17, 5): The expected type comes from property 'each' which is declared here on type 'IntrinsicAttributes & { each: false | readonly any[] | null | undefine...
How to make array key in resource from useRouteData reactive
useRouteData
is an object, then its keys will mostly be reactive -- but if the key has an array as its value, that key will not be reactiveExample:
const data useRouteData();
data().name // reactive
data().groceryList[0] // not reactive
If I just stringify this value on the server and then parse it on the client, then that works just fine, but I'm wondering if there is any way to make it reactive?
The associated `route...
possible to cancel back button with solid router?
createResource from the main layout causes it to completely crash the page
I have a
dashboard.tsx
main layout file and 2 routes inside this dashboard route, and inside this layout I have these resources```ts
export const routeData = () => {
const project = createResource(async () => {
try {
const projectRes = await getProject();
return projectRes!.data;
} catch (error: any) {
console.log("couldn't get project info", error.message);
}
});
const user = createResource(async () => {
try {
const e = useServerContext();...
Rendering Solid inside another app