Skip to content

.bind calls in custom renderer docs pass container as 'this' value, not first param #225

Closed
@RoystonS

Description

@RoystonS

The library README includes the following bit of sample code when suggesting how to write a custom renderer in order to change the 'testid' attribute:

const customRender = (container, options) => {
  const utils = render(container, options)

  return {
    ...utils,
    getByTestId: getByTestId.bind(container),
    getAllByTestId: getAllByTestId.bind(container),
    queryByTestId: queryByTestId.bind(container),
    queryAllByTestId: queryAllByTestId.bind(container),
  }
}

I might have got completely the wrong end of the stick, but should those .bind() calls not have en extra first null parameter? Otherwise they're passing container in as the this value to those functions rather than as the first parameter, as I think is intended?

Suggested solution:

Change them all to .bind(null, container)

Happy to submit a PR...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions