Skip to content

Comments

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

Open
soda0289 wants to merge 1 commit intonayaabkhan:masterfrom
soda0289:master
Open

Add forwardRef option to translate HOC to allow passing down ref#20
soda0289 wants to merge 1 commit intonayaabkhan:masterfrom
soda0289:master

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