Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Conversation

@layershifter
Copy link
Member

@layershifter layershifter commented Nov 21, 2018

Refs #417.


This PR will add automatic refs to all our components. The basic idea of this is quite simple, I tried to document it in comments however I also want to describe it separately in this PR.


1. Wrap all our components with forwardRef()

forwardRef() is a single API that allows you to pass down refs to elements. In fact, forwardRefFactory() is only a wrapper around it. We will wrap all components with it.

This means that we will receive a ref in our factory and catch it:

<Button ref={/* this ref */} />

2. Pass down intercepted refs

  1. Any intercepted ref will be assigned to the forwardRefSymbol prop.
  2. Because forwardRefSymbol is a simple prop we will have it in unhandled props
  3. As all unhandled props are assigned to an ElementType element it will work without any code changes

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will move this to a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of side effects, a component's description should be on export.

@layershifter layershifter changed the title [WIP] feat(refs): add support of automatic refs [WIP] BREAKING(refs): add support of automatic refs Nov 21, 2018
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it part of public API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, and it's a problem. I don't know any other way to perform this check, I have even made a codesandbox that shows my problem: https://codesandbox.io/s/kwkw3pq1k3

I'm open for better proposals there.

@layershifter
Copy link
Member Author

#587 (comment)

@layershifter layershifter deleted the feat/ref-factories branch December 10, 2018 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

⚙️ enhancement New feature or request 🚧 WIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants