-
| 
         I use the destructuring method, and the following code runs correctly: import type { Accessor } from 'solid-js';
import { createSignal } from 'solid-js';
import { render } from 'solid-js/web';
function Counter() {
  const [count, setCount] = createSignal(1);
  const increment = () => setCount((count) => count + 1);
  return <Child count={count} increment={increment} />;
}
interface ChildProps {
  count: Accessor<number>;
  increment: () => void;
}
// Destructuring is used here
function Child({ count, increment }: ChildProps) {
  return (
    <div>
      child <button onClick={increment}>{count()}</button>
    </div>
  );
}
render(() => <Counter />, document.getElementById('app')!);This way also maintains uniformity in use.  | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            atk
          
      
      
        Jul 18, 2024 
      
    
    Replies: 1 comment 2 replies
-
| 
         Once you use stores, you need to wrap the access in functions, which is unwieldy, thus we tend to avoid it.  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Let me elaborate then. Consider you have a component that takes a prop. The parent feeds that prop from a store. Currently, it looks like this:
To keep it reactive, we would have to make a function out of the prop:
Since it is easier to forget always passing functions than it is to remind not t…