Guillaume
Guillaume
SSolidJS
Created by Guillaume on 9/23/2024 in #support
Type for two-element array event handlers
Hi, is there a defined type for two-element array event handlers e.g. onClick={[callback, arg]}. An example code:
type FooComponent = Component<{
onClick: ???,
}>

const Foo: FooComponent = props => (
<div onClick={props.onClick}>
</div>
)
type FooComponent = Component<{
onClick: ???,
}>

const Foo: FooComponent = props => (
<div onClick={props.onClick}>
</div>
)
? I tried
type FooComponent = Component<{
onClick: JSX.EventHandler<HTMLElement, MouseEvent>,
}>
type FooComponent = Component<{
onClick: JSX.EventHandler<HTMLElement, MouseEvent>,
}>
but it does not accept the callback. I also tried
type FooComponent = Component<{
onClick: [(idx: number) => void, number]
}>
type FooComponent = Component<{
onClick: [(idx: number) => void, number]
}>
but that does not match the JSX onClick type.
2 replies
SSolidJS
Created by Guillaume on 9/21/2024 in #support
Proxy error
Hi, I'm a beginner in Solid and I wrote a little app to learn it. https://github.com/gbagan/nim-machine/blob/test/src/App.tsx In this app, I have created a store state which contains an attribute config (line 42) Then, I wrote a function changeConfig which modifies the store (line 132)
const changeConfig = (fn: (c: Config) => Config) => {
setState(produce(state => {
state.config = fn(state.config);
state.victories = 0;
state.losses = 0;
state.isRunning = false;
const graph = getGraph(state);
state.machine = graphToMachine(graph, state.config.ballsPerColor);
}))
}
const changeConfig = (fn: (c: Config) => Config) => {
setState(produce(state => {
state.config = fn(state.config);
state.victories = 0;
state.losses = 0;
state.isRunning = false;
const graph = getGraph(state);
state.machine = graphToMachine(graph, state.config.ballsPerColor);
}))
}
When, this function is called, I obtain the following message error: Uncaught TypeError: proxy must report the same value for the non-writable, non-configurable property 'Symbol("solid-proxy")' on the line state.config = fn(state.config). Initially I wrote this function differently (without using produce) and it worked fine. I'd like to understand this error and how to prevent it.
5 replies