Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6aea435

Browse files
committed
feat: improve store context types
1 parent9c52018 commit6aea435

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

‎packages/store/src/create-state-methods/create-methods-proxy.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export const createMethodsProxy = <TStore extends ZustandStoreApi<any>>({
1818
path:string[]=[],
1919
// py passing the innerObj, we allow for the proxy to be used as a normal object
2020
// this is useful for accessing the target methods of store directly eg store.extend()
21-
innerObj:any={}
21+
innerObj:any={
22+
// __STORE_META__: {
23+
// isDavstackStore: true,
24+
// },
25+
}
2226
){
2327
constproxy:unknown=newProxy(innerObj,{
2428
get(target,key,receiver){

‎packages/store/src/create-store-context/create-store-context.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ export function createStoreContext<TCreator extends StoreApi<any, any> | AnyFn>(
6565
constuseStore=()=>{
6666
constlocalStore=React.useContext(Context);
6767

68-
if(localStore)returnlocalStore;
68+
if(localStore)returnlocalStoreasStoreInstance;
6969

7070
thrownewError('useLocalStore must be used within a LocalProvider');
7171
};
7272

73-
constwithProvider=<TPropsextendsobject>(Component:React.FC<TProps>)=>{
73+
constwithProvider=<TPropsextendsunknown>(Component:React.FC<TProps>)=>{
7474
constWrappedComponent=forwardRef((props:TProps&StoreParams,ref)=>{
7575
return(
7676
<Provider{...props}>
@@ -83,7 +83,8 @@ export function createStoreContext<TCreator extends StoreApi<any, any> | AnyFn>(
8383
Component.displayName||Component.name||'Component'
8484
})`;
8585

86-
returnWrappedComponent;
86+
// casting this type here makes it simpler in the IDE but not sure if it has any unintended side effects
87+
returnWrappedComponentasReact.FC<TProps&StoreParams>;
8788
};
8889

8990
return{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp