Search code examples
reactjsdjangoreduxdjango-rest-framework

Why using Django and React requires so much extra packages?


I have been going through a tutorial (https://www.youtube.com/watch?v=GieYIzvdt2U) where you have to use Babel, Webpack, and Redux which are all complicated in their regards. Why we can not use "djangorestframework" as my API and get the information using that API from React using JS. What do I gain using all these packages or I can not simply use what I am suggesting?


Solution

  • React doesn't just use JavaScript, it also uses JSX which cannot be run natively on a client web browser. JSX is a syntax extension of JS and allows for you to simulate templating of HTML.

    Babel is a compiler. It compiles React's language (JSX) into valid javascript so that it can run on a web browser.

    Webpack is a bundler. It minifies your compiled JS and CSS files and optimises it so that it can run more efficiently on a client's machine. Babel and Webpack are essential to the running of React Apps and even creating a react app using the traditional create-react-app command initialises your development setup to use Babel and Webpack under the hood.

    Redux is separate. Redux is a state management tool that is purely used for development purposes (simplifies or complicates it, that's for you to decide!). You don't have to use Redux, you could opt to do your own state management, or use React Context.

    In the next part, you communicate with your Django API using a library called Axios. Babel, Webpack, and Redux won't have any impact on that.