Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
next-redux-store
Advanced tools
Readme
Next integration with Redux.
Features:
npm i next-redux-store
import { makeStore, Provider } from 'modules/redux';
import { createUseStore } from 'next-redux-store';
import { AppProps } from 'next/app';
// Note that makeStore must accept preloadedState as an argument
const useStore = createUseStore(makeStore);
export default function _App(appProps: AppProps<any>) {
const { Component, pageProps } = appProps;
const store = useStore(appProps);
return (
<Provider store={store}>
<Component {...pageProps} />
</Provider>
);
}
import { makeStore } from 'modules/redux';
import { createGetInitialProps } from 'next-redux-store/server';
const getInitialState = async (appProps, ctx) => {
const store = makeStore();
// Fill the store considering the App props and Document context
// See example (https://github.com/fakundo/next-redux-store/blob/master/packages/docs/pages/_document.tsx#L14)
return store.getState();
}
export default class _Document extends Document {
static getInitialProps = createGetInitialProps(getInitialState);
render() {
...
}
}
import { serverSideState } from 'next-redux-store/server';
export const getStaticProps = async () => {
const store = makeStore();
// Fill the store
const initialState = store.getState();
return {
props: {
...serverSideState(initialState),
},
};
}
createUseStore creates a React hook that returns a Redux store. It accepts a store creation function with a preloadedState as parameter. The hook accepts App props.
type MakeStore = (preloadedState: any | undefined) => Store;
const createUseStore: (makeStore: MakeStore) => (appProps: AppProps<any>) => Store;
createGetInitialProps creates a function that returns initial props for the Document, providing initialState of store for the App.
type CreateInitialState = (appProps: AppProps<any> | undefined, ctx: DocumentContext) => any;
const createGetInitialProps: (createInitialState: CreateInitialState) => (ctx: DocumentContext) => DocumentInitialProps;
createInitialState can accept two parameters: App props and Document context.
serverSideState accepts state of the store and returns page props.
HYDRATE returns hydration action name.
MIT
FAQs
Next integration with Redux
We found that next-redux-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).