-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[RFR] Use hooks in controllers #3213
Conversation
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.
Super encouraging. I'm amazed at how compact and expressive the code looks when we use hooks.
isLoading: boolean; | ||
translate: Translate; | ||
} | ||
export const getRecord = ({ state, search }, record: 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 should live in the reducers directory as it's a selector (same with the test of this function)
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.
Agreed, I will extract selectors
location: { state, search }, | ||
record, | ||
} = this.props; | ||
this.record = |
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 you've broken the clone feature by not porting this
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.
The e2e tests disagree with you ;)
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.
And btw I ported this. This is the getRecord
function you commented earlier
version, | ||
} = this.props; | ||
useEffect(() => { | ||
dispatch(resetForm(REDUX_FORM_NAME)); |
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.
resetForm wasn't called on mount in the previous version. Isn't there a consequence of calling it here?
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 we have e2e tests for this case but I will check
This looks cool thanks! Will we have a part about what are controllers in the documentation (RFC style)? |
See the roadmap 😉 (#3194) |
Awesome! |
🤗 Now we can extract custom hooks 🚀 ! |
I believe the first step before migrating our controller components to custom hooks is to make them use hooks in the first place.
CreateController
EditController
ShowController
ListController