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
/keaPublic

Commit6f05ff6

Browse files
committed
Fix bug with deriving default key from undefined props.
1 parente5b3853 commit6f05ff6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
##3.1.5 - 2023-03-16
6+
- Fix bug with deriving default key from undefined props.
7+
58
##3.1.4 - 2023-01-16
69

710
- Support searching by key in`logic.findMounted(123)` and`logic.isMounted('string key')`.

‎src/kea/kea.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function kea<L extends Logic = Logic>(
109109
}
110110
wrapper.find=(keyOrProps?:Record<string,any>|KeyType)=>{
111111
constbuiltLogic=
112-
typeofkeyOrProps==='object'
112+
typeofkeyOrProps==='object'||typeofkeyOrProps==='undefined'
113113
?getCachedBuiltLogicByProps<L>(wrapper,keyOrProps)
114114
:getCachedBuiltLogicByKey<L>(wrapper,keyOrProps)
115115
if(builtLogic&&getContext().mount.counter[builtLogic.pathString]>0){

‎test/jest/mount.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{kea,resetContext,getContext}from'../../src'
1+
import{kea,resetContext,getContext,path,key}from'../../src'
22

33
describe('mount',()=>{
44
beforeEach(()=>{
@@ -193,4 +193,10 @@ describe('mount', () => {
193193
expect(logic.isMounted()).toEqual(true)
194194
})
195195
})
196+
197+
test('can mount logic with default key',()=>{
198+
constlogic=kea([path((key)=>['scenes','misc',key]),key(({ id})=>id??'default')])
199+
logic.mount()
200+
expect(logic.isMounted()).toEqual(true)
201+
})
196202
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp