ReasonReact

ReasonReact

  • Docs
  • Try
  • Examples
  • Community
  • Blog
  • Languages iconEnglish
    • 日本語
    • Español
    • Français
    • 한국어
    • Português (Brasil)
    • Русский
    • 中文
    • 繁體中文
    • Help Translate
  • GitHub

›Recipes & Snippets

Recipes & Snippets

  • A List of Simple Examples
  • Adding data-* attributes
  • Working with Optional Data
  • Render Props
  • Importing JS into Reason
  • Importing Reason into JS
  • ReasonReact using ReactJS
  • ReactJS using ReasonReact
  • Example Projects
  • GraphQL & Apollo
  • Styling: Tailwind CSS
Edit

Importing Reason into JS

Importing a Basic Reason file into Javascript

/* Greeting.re */

[@react.component]
let make = (~name) => <span> {React.string("Hey " ++ name)} </span>;
/* App.js */

import { make as Greeting } from './Greeting.bs'

export default function App() {
    return <Greeting name="Peter" />
}

Importing a Component as Default

/* Greeting.re */

[@react.component]
let make = (~name) => <span> {React.string("Hey " ++ name)} </span>;

/* this sets the named export to default */
let default = make;
/* App.js */

import Greeting from './Greeting.bs'

export default function App() {
    return <Greeting name="Peter" />
}
← Importing JS into ReasonReasonReact using ReactJS →