Skip to content
This repository was archived by the owner on Mar 15, 2023. It is now read-only.

Commit 8ad4696

Browse files
committed
🐛 Fix major issue with provider orders in createApp util
1 parent b739f74 commit 8ad4696

File tree

7 files changed

+80
-77
lines changed

7 files changed

+80
-77
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
"@babel/core": "^7.12.10",
3333
"@babel/preset-typescript": "^7.12.7",
3434
"@rollup/plugin-babel": "^5.2.2",
35-
"@rollup/plugin-node-resolve": "^11.0.1",
35+
"@rollup/plugin-node-resolve": "^11.1.0",
3636
"@skypack/package-check": "^0.2.2",
3737
"babel-preset-solid": "^0.23.8",
3838
"prettier": "^2.2.1",
39-
"rollup": "^2.36.1",
39+
"rollup": "^2.36.2",
4040
"rollup-plugin-analyzer": "^4.0.0",
4141
"rollup-plugin-delete": "^2.0.0",
4242
"typescript": "^4.1.3"
4343
},
4444
"dependencies": {
45-
"solid-js": "^0.23.10"
45+
"solid-js": "^0.23.11"
4646
},
4747
"peerDependencies": {
4848
"solid-js": "^0.23"

playground/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { createApp, createStore, createGlobalState, createGlobalSignal } from '..';
1+
import { createApp, createStore, createGlobalState, createGlobalSignal } from '../src';
22

33
const [globalState, setGlobalState] = createGlobalState({ name: 'hello' });
44
const [globalSignal, setGlobalSignal] = createGlobalSignal(20);
55

66
const [Provider, useProvider] = createStore({
77
state: (props) => ({ count: props.count }),
88
actions: (set) => ({ inc: () => set('count', (c) => c + 1) }),
9-
effects: (_, get) => [() => console.log(get.count)],
9+
effects: (set, get) => [() => console.log(get.count)],
1010
props: { count: 0 },
1111
});
1212

playground/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"dev": "vite"
7+
"dev": "vite",
8+
"build": "vite build"
89
},
910
"keywords": [],
1011
"author": "Alexandre Mouton-Brady",
1112
"license": "ISC",
1213
"devDependencies": {
1314
"babel-preset-solid": "^0.23.8",
14-
"vite": "^2.0.0-beta.5",
15-
"vite-plugin-solid": "^0.6.0"
15+
"vite": "^2.0.0-beta.44",
16+
"vite-plugin-solid": "^0.7.0"
1617
},
1718
"dependencies": {
18-
"solid-js": "^0.23.10"
19+
"solid-js": "^0.23.11"
1920
}
2021
}

playground/pnpm-lock.yaml

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

pnpm-lock.yaml

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

src/createApp.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Component } from 'solid-js';
1+
import type { JSX, Component } from 'solid-js';
22
import { createComponent, render } from 'solid-js/web';
33

44
interface App {
@@ -50,22 +50,22 @@ interface Provider {
5050
* )
5151
*/
5252
function mergeProviders(app: () => Element, providers: Provider[]) {
53-
return providers.reduceRight((application, { provider, opts }) => {
53+
return providers.reduceRight<JSX.Element | undefined>((application, { provider, opts }) => {
5454
return createComponent(provider, {
5555
...opts,
5656

5757
get children() {
58-
return application;
58+
return application || createComponent(app, {});
5959
},
6060
});
61-
}, app);
61+
}, undefined);
6262
}
6363

6464
export function createApp<T extends unknown>(app: T) {
6565
const providers: Provider[] = [];
6666

6767
const _app: App = {
68-
use(provider, opts) {
68+
use(provider, opts = {} as any) {
6969
providers.push({ provider, opts });
7070
return _app;
7171
},

0 commit comments

Comments
 (0)