SolidJSS
SolidJSโ€ข16mo agoโ€ข
4 replies
jrainearwills

`createContext`, What's the point?

In SolidJS, It looks like I can create a store in a JS module, then import the state and setters to any component in my app. That said, is there an advantage to using a context or is it there for convenience?

This works like as far as I can tell:
// store.ts
export const [appState, setAppState] = createStore({globalValue: "I'm alive!"});

// App.tsx
import {appState} from './store.ts'

export default function App(){
    return (
        <h1>{appState.globalValue}</h1>
    )
}
Was this page helpful?