9

I've been following closely Remix Run JS (https://remix.run/) and I've been working with some tutorials, however, I haven't found anywhere here or in the web of how to implement a redux store:

I was thinking in wrapping the App component like this but I'm not sure if that's how it should be done:

const store = createStore(rootReducer);

export default function App() {
  return (
    <Provider store={store}>
      <html lang="en">
        <head>
          <meta charSet="utf-8" />
          <meta name="viewport" content="width=device-width,initial-scale=1" />
          <Meta />
          <Links />
        </head>
        <body>
          <Link to="/posts">Posts</Link>
          <Outlet />
          <ScrollRestoration />
          <Scripts />
          {process.env.NODE_ENV === "development" && <LiveReload />}
        </body>
      </html>
    </Provider>
  );
}
Fer Toasted
  • 1,274
  • 1
  • 11
  • 27
  • I am curious why you need redux at all? Or if you do have a complex state management requirement for your app, why do you want to use Remix? Remix as a framework tries to avoid this sort of client side state management. See their blog post about data flow for example: https://remix.run/blog/remix-data-flow – hakeri Jan 04 '23 at 09:10
  • 1
    As you mentioned, it all depends on your needs. I usually work with complex states in my apps and therefore require libraries such as redux (Zustand sometimes works too), and while playing with Remix I got curious about a possible Redux implementation for it. Loaders work in 90% of the use cases tbh. – Fer Toasted Jan 04 '23 at 15:49
  • Redux has its uses, but as @hakeri mentioned, you don't really need redux and as Remix tries to remove all of that state complexity. – Abdi Jan 10 '23 at 17:19
  • 3
    Sorry, I still think that redux is needed in "some" cases. Most of the time that should be covered with `loaders/useContext`, but I still think that this is a valid —probably not usual— use case. – Fer Toasted Jan 10 '23 at 17:27
  • Imagine the following: You got a huge application based on a lot of things. The User experience divides into a lot of clients. There is for example a webapp a native app and an desktop application. They'r all using the same entities and working with the same logic, each of them was build with Typescript. Why should i reimplement the logic for each application if i could just use a state management install it and share logic and even test logic together ? – Tjerk Haaye Henricus Dames Jun 10 '23 at 08:43

0 Answers0