We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
See #201 for working starting points
The text was updated successfully, but these errors were encountered:
Just copied this code into a third project:
import React from 'react'; import PropTypes from 'prop-types'; import { curry } from 'ramda'; import Error from 'next/error'; import { getCurrentActiveFeatureNames, isActiveFeatureName, } from '@paralleldrive/feature-toggles'; const configureNextPageFeature = ( initialFeatures, featureName, ComposedComponent ) => { const getComposedComponentsInitialProps = ctx => ComposedComponent.getInitialProps ? ComposedComponent.getInitialProps(ctx) : {}; const NextPageFeature = ({ statusCode, ...rest }) => statusCode === 200 ? ( <ComposedComponent {...rest} /> ) : ( <Error statusCode={statusCode} /> ); NextPageFeature.getInitialProps = async ctx => { const { res, req, err } = ctx; const activeFeaturesNames = getCurrentActiveFeatureNames({ initialFeatures, req, }); if (res && !isActiveFeatureName(featureName, activeFeaturesNames)) res.statusCode = 404; const statusCode = res ? res.statusCode : err ? err.statusCode : null; return { ...(await getComposedComponentsInitialProps(ctx)), statusCode, }; }; NextPageFeature.propTypes = { statusCode: PropTypes.number.isRequired, }; return NextPageFeature; }; export default curry(configureNextPageFeature);
Do we have something like this in the library yet?
Sorry, something went wrong.
No branches or pull requests
See #201 for working starting points
The text was updated successfully, but these errors were encountered: