Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
next-redux-store
Advanced tools
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({ Component, pageProps, ...rest }: AppProps<any>) {
const store = useStore(rest);
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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.