Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Getting the named type of props for a React component

$
0
0

Suppose I’ve written a React component and elsewhere I want to construct a props object that I can feed into that component. How to do this? Ideally I’d like to be able to do something like Component.make to make the component, and Component.propType to see the prop type. I thought something like this existed before, Component.makeProps, but can’t do this now.

@react.component
let make = (~x, ~y) => {
  <div>
    <div> {React.string("x: " ++ Int.toString(x))} </div>
    <div> {React.string("y: " ++ Int.toString(y))} </div>
  </div>
}

let makeParamsDoubled : nameOfPropsTypeHere = (x, y) => {
  x: x * 2,
  y: y * 2,
}


Viewing all articles
Browse latest Browse all 2592

Trending Articles