Skip to content
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

Add forwardRef option to translate HOC to allow passing down ref #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

soda0289
Copy link

@soda0289 soda0289 commented Jul 5, 2019

Currently if a component is wrapped with translate() HOC it cannot have a ref passed into it. This commit adds an option called forwardRef that will use React.forwardRef to pass down the ref from the _translate component into the wrapped component.

Still need to add tests but want to make sure this change is ok before working on it more.

@soda0289 soda0289 force-pushed the master branch 2 times, most recently from ad14d9e to 159aae2 Compare July 18, 2019 20:22
{t => <WrappedComponent {...props} t={t} />}
</I18nContext.Consumer>
)
const _translate = originalProps => {
Copy link
Owner

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace originalProps with (originalProps)

Suggested change
const _translate = originalProps => {
const _translate = (originalProps) => {


return (
<I18nContext.Consumer>
{t => <WrappedComponent {...props} t={t} ref={forwardedRef} />}
Copy link
Owner

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace t with (t)

Suggested change
{t => <WrappedComponent {...props} t={t} ref={forwardedRef} />}
{(t) => <WrappedComponent {...props} t={t} ref={forwardedRef} />}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants