SolidJSS
SolidJSโ€ข3y agoโ€ข
4 replies
jesseb34r

how to add function call into JSX

I have a component setup like
<GameRoot>
  <Zone id="players" />
  <Zone id="battlefield" />
  <Zone id="info" />
</GameRoot>

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 not
Was this page helpful?