Skip to content

Commit 01c661f

Browse files
Migrate to SolidBase tabs and package helper (#1135)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 41de7ae commit 01c661f

37 files changed

+388
-1346
lines changed

app.config.ts

+49
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,55 @@ export default defineConfig(
8181
toc: {
8282
minDepth: 2,
8383
},
84+
packageManagers: {
85+
presets: {
86+
npm: {
87+
install: "npm i :content",
88+
"install-dev": "npm i :content -D",
89+
"install-global": "npm i :content -g",
90+
"install-local": "npm i",
91+
run: "npm run :content",
92+
exec: "npx :content",
93+
create: "npm init :content",
94+
},
95+
pnpm: {
96+
install: "pnpm i :content",
97+
"install-dev": "pnpm i :content -D",
98+
"install-global": "pnpm i :content -g",
99+
"install-local": "pnpm i",
100+
run: "pnpm :content",
101+
exec: "pnpx :content",
102+
create: "pnpm create :content",
103+
},
104+
yarn: {
105+
install: "yarn add :content",
106+
"install-dev": "yarn add :content -D",
107+
"install-global": "yarn add :content -g",
108+
"install-local": "yarn i",
109+
run: "yarn :content",
110+
exec: "yarn dlx :content",
111+
create: "yarn create :content",
112+
},
113+
bun: {
114+
install: "bun i :content",
115+
"install-dev": "bun i :content -d",
116+
"install-global": "bun i :content -g",
117+
"install-local": "bun i",
118+
run: "bun run :content",
119+
exec: "bunx :content",
120+
create: "bun create :content",
121+
},
122+
deno: {
123+
install: "deno add npm::content",
124+
"install-dev": "deno add npm::content -D",
125+
"install-global": "deno add npm::content -g",
126+
"install-local": "deno i",
127+
run: "deno run :content",
128+
exec: "dpx :content",
129+
create: "deno run -A npm::content",
130+
},
131+
},
132+
},
84133
},
85134
}
86135
)

pnpm-lock.yaml

+10-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/concepts/context.mdx

+13-24
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ This offers a way to access state across an application without passing props th
2121
Context is created using the [`createContext`](/reference/component-apis/create-context) function.
2222
This function has a `Provider` property that wraps the component tree you want to provide context to.
2323

24-
<TabsCodeBlocks>
25-
<div id="/context/create.js">
26-
```jsx
24+
```jsx tab title="/context/create.js"
2725
import { createContext } from "solid-js";
2826

2927
const MyContext = createContext();
3028
```
31-
</div>
32-
<div id="/context/component.jsx">
33-
```jsx
29+
30+
```jsx tab title="/context/component.jsx"
3431
import { MyContext } from "./create";
3532

3633
export function Provider (props) {
@@ -41,8 +38,6 @@ export function Provider (props) {
4138
)
4239
};
4340
```
44-
</div>
45-
</TabsCodeBlocks>
4641

4742
## Providing context to children
4843

@@ -161,9 +156,7 @@ export function CounterProvider(props) {
161156
[Signals](/concepts/signals) offer a way to synchronize and manage data shared across your components using context.
162157
You can pass a signal directly to the `value` prop of the `Provider` component, and any changes to the signal will be reflected in all components that consume the context.
163158
164-
<TabsCodeBlocks>
165-
<div id="App.jsx">
166-
```jsx
159+
```jsx tab title="App.jsx"
167160
import { CounterProvider } from "./Context";
168161
import { Child } from "./Child";
169162

@@ -176,9 +169,8 @@ export function App() {
176169
)
177170
}
178171
```
179-
</div>
180-
<div id="Context.jsx">
181-
```jsx
172+
173+
```jsx tab title="Context.jsx"
182174
import { createSignal, useContext } from "solid-js";
183175

184176
export function CounterProvider(props) {
@@ -204,9 +196,9 @@ export function CounterProvider(props) {
204196

205197
export function useCounter() { return useContext(CounterContext); }
206198
```
207-
</div>
208-
<div id="Child.jsx">
209-
```tsx title="/context/counter-component.tsx"
199+
200+
```tsx tab title="Child.jsx"
201+
// /context/counter-component.tsx
210202
import { useCounter } from "./Context";
211203

212204
export function Child(props) {
@@ -221,8 +213,6 @@ export function Child(props) {
221213
);
222214
};
223215
```
224-
</div>
225-
</TabsCodeBlocks>
226216
227217
This offers a way to manage state across your components without having to pass props through intermediate elements.
228218
@@ -262,12 +252,12 @@ Read more about default values in the [`createContext`](/reference/component-api
262252
:::
263253
264254
Because of this, if an initial value was not passed to `createContext`, the TS type signature of `useContext` will indicate that
265-
the value returned might be `undefined` (as mentioned above).
266-
This can be quite annoying when you want to use the context inside a component, and particularly when immediately destructuring the context.
255+
the value returned might be `undefined` (as mentioned above).
256+
This can be quite annoying when you want to use the context inside a component, and particularly when immediately destructuring the context.
267257
Additionally, if you use `useContext` and it returns `undefined` (which is often, but not always, the result of a bug), the error message thrown at runtime can be confusing.
268258
269-
The most common solution for it is to wrap all uses of `useContext` in a function that will explicitly throw a helpful error if the context is `undefined`.
270-
This also serves to narrow the type returned, so TS doesn't complain.
259+
The most common solution for it is to wrap all uses of `useContext` in a function that will explicitly throw a helpful error if the context is `undefined`.
260+
This also serves to narrow the type returned, so TS doesn't complain.
271261
As an example:
272262
273263
```ts title="/context/counter-component.tsx"
@@ -279,4 +269,3 @@ function useCounterContext() {
279269
return context
280270
}
281271
```
282-

0 commit comments

Comments
 (0)