Question on Functions vs Components
Hey all! I have a quick question. What is the difference between using plain functions versus using components when both return JSX? I realized just now I accidentally had used functions instead of components in my code but when I changed them to components, it broke the functionality. Is it okay to use either or?
6 Replies
Can you post an example of a component that's not a function?
ouff, the formatting on that is terrible, ill probably send a playground solidjs playground
this is a function returning a component
(a component is just a function returning JSX)
I see, this is the return of my LayerPanel function
So there is/isn't a difference in using {SourceDropdown()} versus <SourceDropdown />?
the only difference is that
<SourceDropdown />
gets automatically untrack
ed
while the other one doesn't
+ some minor only-in-development differencesSo if I wanted to switch from functions to <SourceDropdown /> would I have to pass the signals into each of the components manually? Because for example, levels depends on the source and field signals defined in a higher scope and (I think) the components scope doesnt work the same as the functions