Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

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

    Thomas GrecoThomas Greco

    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
    reasonReason
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss