Description
There's an issue with the observer HOC when using the <Redirect> component from expo-router together with useSub. The error adm.onStoreChange is not a function is thrown, although the redirect itself works correctly.
Steps to Reproduce
- Create a component that uses
observer, useSub, and conditionally renders a <Redirect> component
- Subscribe to a non-existent document using
useSub
- Return a
<Redirect> component when the document doesn't exist
Code Example
Broken code (throws error):
import { observer, pug, $, useSub } from 'startupjs'
import { Div, Span } from 'startupjs-ui'
import { Redirect } from 'expo-router'
export default observer(function TransactionPage () {
const $t = useSub($.transactions['1-2-3-4'])
const tt = $t.get()
if (!tt) {
return <Redirect href='/' />
}
return pug`
Div.root
Span.text Hello, world!
`
})
Working workaround:
import { observer, pug, $, useSub } from 'startupjs'
import { Div, Span } from 'startupjs-ui'
import { useRouter } from 'expo-router'
export default observer(function TransactionPage () {
const $t = useSub($.transactions['1-2-3-4'])
const router = useRouter()
const tt = $t.get()
if (!tt) {
router.replace('/')
}
return pug`
Div.root
Span.text Hello, world!
`
})
Error: adm.onStoreChange is not a function

Description
There's an issue with the
observerHOC when using the<Redirect>component fromexpo-routertogether withuseSub. The erroradm.onStoreChange is not a functionis thrown, although the redirect itself works correctly.Steps to Reproduce
observer,useSub, and conditionally renders a<Redirect>componentuseSub<Redirect>component when the document doesn't existCode Example
Broken code (throws error):
Working workaround:
Error: adm.onStoreChange is not a function