Docs Index

Doc

Redux

Last updated on

Redux is both a powerful and widely used global state library. While Redux usage in React has historically been split between two packages (“redux” and “react-redux”), the Redux maintainers have introduced a new package to help reduce boilerplate called “Redux Toolkit”. Redux Toolkit is the official way to build new Redux applications.

To use Redux with React, you’ll need to start with the JSX React package that’s provided in CoderPad. Once there, you’ll need to add the CDN for Redux, React Redux, and Redux Toolkit. These libraries will be available as global variables “Redux”, “ReactRedux” and “RTK” respectively.

<html> <head> <meta charset="UTF-8" /> <title>Hello World</title> <script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script> <script src="https://unpkg.com/@babel/standalone@7.13.12/babel.min.js"></script> <script src="https://unpkg.com/@reduxjs/toolkit@1.5.1/dist/redux-toolkit.umd.min.js"></script> <script src="https://unpkg.com/redux@4.1.0/dist/redux.js"></script> <script src="https://unpkg.com/react-redux@7.2.4/dist/react-redux.js"></script> </head> <body> <div id="root"></div> <script type="text/babel"> console.log(RTK); console.log(ReactRedux); console.log(Redux); </script> </body> </html>
Code language: HTML, XML (xml)

For a look at how RTK can be used in a small example, here’s the default RTK code sample in CoderPad