Skip to content

Commit

Permalink
Merge branch 'main' into remove-data-loading-page
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jan 1, 2025
2 parents b8a26e0 + 17509cd commit f9676e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
21 changes: 11 additions & 10 deletions src/routes/reference/component-apis/create-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,36 @@ For example:
```ts title="/context/counter.ts"
import { createContext } from "solid-js";

export const DEFAULT_COUNT = 0
const INTIAL_STORE_SETTER = {
increment: () => void,
decrement: () => void
export const INITIAL_COUNT = 0;

const INITIAL_STORE_SETTER = {
increment: () => {},
decrement: () => {}
};

export const CounterContext = createContext([
{ count: INITIAL_COUNT },
INTIAL_STORE_SETTER
INITIAL_STORE_SETTER
]);
```

With the context created in its own module, you can use to instantiate the context provider.

```ts title="/context/counter-component.tsx"
import { createStore } from 'solid-js/store';
import { CounterContext, DEFAULT_COUNT } from "./counter.ts";
import { CounterContext, INITIAL_COUNT } from "./counter.ts";

export function CounterProvider(props) {
const [value, setValue] = createStore({ count: props.initialCount || DEFAULT_COUNT })
const [value, setValue] = createStore({ count: props.initialCount || INITIAL_COUNT })

const counter = [
const counter = [
value,
{
increment() {
setValue("count", currentCount => currentCount + 1)
},
decrement() {
setValue("count", currentcount => currentCount - 1)
setValue("count", currentCount => currentCount - 1)
},
},
]
Expand Down Expand Up @@ -98,4 +99,4 @@ interface Context<T> {
}

function createContext<T>(defaultValue?: T): Context<T | undefined>
```
```
8 changes: 5 additions & 3 deletions src/routes/solid-router/advanced-concepts/lazy-loading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ In Solid Router, you can lazy load components using the `lazy` function from Sol
import { lazy } from "solid-js";
import { Router, Route } from "@solidjs/router";

const Home = () => import("./Home");
const Home = lazy(() => import("./Home"));

const Users = lazy(() => import("./Users"));

const App = () => (
<Router>
<Route path="/" component={<Home />} />
<Route path="/users" component={<Users />} />
<Route path="/" component={Home} />
<Route path="/users" component={Users} />
</Router>
);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ This will allow you to create a new route that is not nested under the previous
|-- routes/ // example.com
|-- users/
|-- index.tsx // example.com/users
|-- projects.tsx // example.com/projects
|-- projects.tsx // example.com/users/projects
|-- users(details)/
|-- [id].tsx // example.com/users/1
```
Expand Down
4 changes: 1 addition & 3 deletions src/ui/layout/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ export const Hero: Component = () => {
>
<Index each={snippetLines}>
{(_, index) => (
<pre class="pb-px">
{(index + 1).toString().padStart(2, "0")}
</pre>
<pre>{(index + 1).toString().padStart(2, "0")}</pre>
)}
</Index>
</div>
Expand Down

0 comments on commit f9676e0

Please sign in to comment.