Created
May 1, 2020 12:55
-
-
Save alexmccabe/0be194bcd15de2f18616ed1ada307ba4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set up the Create Account Form | |
* | |
* 1. So this complicated mess is because the connect() function doesn't | |
* support forwardRef(). The trick is to create a new "connected" version of | |
* our base component. | |
* | |
* 2. And then create the exported version which is wrapped in the forwardRef() | |
* and given a displayName. This stops the linters from failing and allows | |
* forwarding of refs. | |
*/ | |
/* [1] */ | |
const CreateDiscusssionFormConnected = connect(mapStateToProps, { | |
loadPostCategories, | |
loadTags, | |
})(CreateDiscusssionForm); | |
/* [2] */ | |
const ExportedComponent = forwardRef((props, ref) => ( | |
<CreateDiscusssionFormConnected {...props} innerRef={ref} /> | |
)); | |
ExportedComponent.displayName = 'CreateDiscusssionForm'; | |
export default ExportedComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment