Use BuckleScript to get up and running in a new ReasonReact project

Thomas Greco
InstructorThomas Greco

Share this video with your friends

Send Tweet
Published 4 years ago
Updated 3 years ago

This lesson shows viewers how to get up and running in a new ReasonReact application using Bucklescript's bsb command-line tool.

To access bsb on your local machine you can install globally by running

npm install -g bs-platform

Instructor: [00:01] We can use BuckleScript to initialize a new ReasonReact app using BSB with the init flag, and then specifying the directory of the project, which is new app. We'll also need to use the theme flag and give that a value of React.

[00:19] Once our project's created, we'll need to change directories into it and install the necessary dependencies. When they finish installing, we can then execute npm Run Start, which will fire off the process of our Reason files being compiled to BuckleScript.

[00:37] While those are compiling, we'll also want to go into another terminal and execute the npm run webpack command. Webpack will watch the BuckleScript files and compile them into a format that can be readable by a browser.

[00:52] Since BuckleScript and Webpack are running, let's check out the code. Inside the project, we'll find the source folder, which is going to hold our Reason files.

[01:03] Currently, the code from this page.reason file is being displayed. To see this, all we need to do is copy the path of the index.html file in here and paste it right into our browser. As you see, that hello is being displayed to the page. You'll also note that there's no server involved.

[01:27] To wrap this up, let's change the string in our handle click function to, "I just clicked the button." When I save that, you'll notice that Reason automatically formatted this file for me. If we do go back to the browser and click on that hello, we'll see our new string being logged to the console.

~ 4 years ago

Do we first install reason-cli ?