Closed zheeeng closed 6 years ago
what exactly did you modify in app.tsx
?
This modification seems break the storing state locally, after routing to another component the inputs' values are read from previous values randomly.
// /src/components/app.tsx
const componentSinks$ = match$.map(
- ({ path, value: { component, scope } }) => {
+ ({ path, value: { component } }) => {
- return isolate(component, scope)({
+ return isolate(component)({
...sources,
router: sources.router.path(path)
})
}
)
In a reality project, removing scope sometimes cause my app stuck after interaction with this app a while, it is hard to make mimal reproduction.
calling isolate without scope argument is not recommended, because it generates a random scope every time it gets called. For your case that means that every time you navigate, you get a new key to store the state under it. In general, we recommend to supply an explicit scope.
I thought that exporting the isolated component is of a best practice before, like below: https://github.com/cyclejs/cyclejs/blob/master/examples/advanced/bmi-nested/src/LabeledSlider.js
So I want to use isolate
without maintaining the scope names.
But then, dont isolate it again. The problem with your code is that it isolates it again on every route change
Thx for your suggestion.
I try to remove the scope config in the src/routes.ts, or rename scopes, this initial demo doesn't work anymore. Why is this 'scope' required for running app? I did the corresponding modifications in
src/components/app.tsx
isolate calling.