Skip to content

Instantly share code, notes, and snippets.

@jihchi
Last active February 8, 2020 06:32
Show Gist options
  • Save jihchi/8583787a4b6cfc2beedbdc65da54b12b to your computer and use it in GitHub Desktop.
Save jihchi/8583787a4b6cfc2beedbdc65da54b12b to your computer and use it in GitHub Desktop.
Wordaround -- Allow data-* in DOM elements -- data-test-id for example -- Reason React
[@react.component]
let make = (~id: string, ~children) =>
ReasonReact.cloneElement(children, ~props={"data-test-id": id}, [||]);

Source: reasonml/reason-react#230 (comment)

Workaround from @yawaramin , Posted by @alexfedoseev

Usage

<WithTestId id="foo"> <button className="primary" /> </WithTestId>
// Output: <button class="primary" data-test-id="foo" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment