Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wouter-redux

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wouter-redux

Use redux state for wouter

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

Wouter Redux

Wouter Redux puts the location history into Redux store so that browser location changes only responds to store changes so that you always get the current location in redux store.

Wouter is a minimalistic router for modern React.

Why

Browse location represents your application state. E.g. pagination parameters. It's usually a good idea to put the state in the URL so that you it's bookmark-able.

If you use redux and keep E.g. pagination outside of the redux state, you'll soon realise you need to select data base on parameters outside of Redux state. This makes writing the selectors tricky

Usage

import { createWouterHook, reducer as routerReducer } from "wouter-redux";
import { configureStore } from "@reduxjs/toolkit";

const store = configureStore({
  reducer: {
    ...
    router: routerReducer,
  },
});
const useLocation = createWouterHook(store);
function App() {
  return (
    <Provider store={store}>
      <Router hook={useLocation}>
        <Route path="/">
          <Home />
        </Route>
        <Route path="/count/">
          <Counter />
        </Route>
      </Router>
    </Provider>
  );
}

TODO

  • test
  • tag v1
  • handle replace in history

Keywords

FAQs

Package last updated on 01 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc