Skip to content

Instantly share code, notes, and snippets.

@alexmccabe
Created May 1, 2020 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexmccabe/0be194bcd15de2f18616ed1ada307ba4 to your computer and use it in GitHub Desktop.
Save alexmccabe/0be194bcd15de2f18616ed1ada307ba4 to your computer and use it in GitHub Desktop.
/**
* 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