-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect as a functional component #150
base: master
Are you sure you want to change the base?
Conversation
packages/core/src/connect.tsx
Outdated
}); | ||
|
||
Object.keys(prevWatched).forEach(pathKey => { | ||
const keyDeleted = watched.current.hasOwnProperty(pathKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUG: missing !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, you mean negation. Good spot!
|
||
public render() { | ||
this.createViewCtx(); | ||
return (func as ((args: any) => (props: any) => any))(ctx)(props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this breaks support for hooks because func(ctx)
will be a different function each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've done this before and I think it worked. Will do some testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think hooks still work. At least the update-testing example works as expected.
Looks like this breaks the dev tools though - looking now but please don't merge. |
logger.debug("store", store); | ||
}, []); | ||
|
||
const pathNodes = React.useRef({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this by typed?
// const getValue = (path: string[], obj: any): any => | ||
// path.reduce((x: any, y: any) => x && x[y], obj); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔫
|
||
// if (seenValue !== getValue(path, store.universe)) { | ||
// console.log(`Not seen ${path} before, so rerendering`); | ||
// node.forceUpdate(); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔫
|
||
return true; | ||
}; | ||
const getValue = (path: string[], obj: any): any => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same as the get
function in watch.ts
. Maybe extract so its only defined once.
Please test before merging - particularly when importing
@prodo/core
from outside of the monorepo.