In certain cases, you might want to choose the DOM element given props, and JSX prevents that.
In JS, you'd do:
React.createElement(multiline ?"textarea" :"input"/* ... */);ReactJS has a special behavior that considers strings as special components. In a typed language, that's a bit trickier. To that end we provideReactDOM.stringToComponent that makes the compiler understand that a given string is to be considered a component.
In Reason:
React.createElement(ReactDOM.stringToComponent(multiline ?"textarea" :"input"),/* ... */)You can also pass a variable:
let tag =ReactDOM.stringToComponent(multiline ?"textarea" :"input");React.createElement(tag,/* ... */)