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

react-http-status

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-http-status

Set the HTTP status code from inside React components

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

konnektid-react-status Build Status

Set the HTTP status code from inside react components

Install

npm install --save konnektid/konnektid-react-status

Client usage

import React from "react";
import StatusCode from "konnektid-react-status";

// render your component
const MyComponent = () => (
    <StatusCode code={404}>
        <div>
            <p>Sorry, page was not found</p>
        </div>
    </StatusCode>   
);

Server usage

import React from "react";
import { renderToString } from "react-dom/server";
import StatusCode from "konnektid-react-status";

// express middleware
const renderPage = (req, res, next) => {

    const html = renderToString(
        React.createElement(MyRootComponent, props)
    );

    // call this AFTER rendering to string!
    const status = StatusCode.rewind();

    // send the status if one was defined
    if (status) res.status(status);

    res.send(html);
};

FAQs

Package last updated on 17 May 2017

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