27
loading...
This website collects cookies to deliver better user experience
git clone https://github.com/facebook/react.git
npm install
to install all its dependencies.Step 3:
React repository uses yarn workspaces, which basically means, that they have divided the library into smaller re-usable packages, if you look at the package.json, you can see that there is a workspaces property which is an array, where they include everything inside packages folder, where they have the actual packages like react and react-dom etc.
We will take a closer look at the react codebase later.
Step 4: Build the react library - yarn build react/index,react/jsx,react-dom/index,scheduler --type=NODE
, this command is going to build the react, react-dom and schedular package, you can simply run the build script to build all packages, but for our purposes we need only react and react-dom.
Step 5 : Once the build command successfully runs, you will see a build folder inside the root of the project, you will see that inside the build folder the packages we built are created inside the node_modules folder, and you will see react and react dom.
Step 1 : Use create-react-app or any other scaffolding tool, I am using cra because its quite popular and scaffold a client app - npx create-react-app react-client
. Do so in a different folder than where you cloned your react code.
Step 2: CRA runs yarn install for you, so if you run the app now, it will use the packages installed in your node modules, which has the react dependency from the online officially released version mentioned in your package json, but what we want is to use the built package we are currently working with. So here in the root directory of your client app run - yarn link react react-dom
yarn start
, once the app runs open the debug window and checkout the path of the react library, it should point to your local build folder path and not the node_modules of your clients, and changes to your local library should reflect in the code your client app runs.