Search code examples
solid-jssolid-start

What is the meaning and significance of starting function names with use and create for SolidJs


I am trying to start a side project with SolidStart and I noticed some functions are named the same way a React hook would be named (eg: useLocation, useParams, etc...)

I am confused by this somewhat since I see many functions that are the analogs of standard react hooks like createSignal, createEffect, createQuery, etc...

Looking at the documentation for both Solid Start and Solid Js I could not find any particular nomenclature for such functions, though I've seen those that start with create being referred to as factories.

React has special rules for hooks, which are functions that start with "use". I'm wondering if there is are any special rules / functionality for functions starting with "create" and "use" in SolidJs and Solid Start.


Solution

  • Solid has no hooks and there are no implicit rules attached to variable names. Although there are no set rules or a style guide on how to choose names, generally function names start with create if they create a signal or an effect or an internal resource. Names with use are usually preferred if the function operates over an existing resource.

    You can find clues on the topic on Ryan Carniato's Youtube streams and in some issues and discussions: