Set the HTTP status code from inside react components
npm install --save konnektid/konnektid-react-statusimportReactfrom"react";importStatusCodefrom"konnektid-react-status";// render your componentconstMyComponent=()=>(<StatusCodecode={404}><div><p>Sorry, page was not found</p></div></StatusCode>);importReactfrom"react";import{renderToString}from"react-dom/server";importStatusCodefrom"konnektid-react-status";// express middlewareconstrenderPage=(req,res,next)=>{consthtml=renderToString(React.createElement(MyRootComponent,props));// call this AFTER rendering to string!conststatus=StatusCode.rewind();// send the status if one was definedif(status)res.status(status);res.send(html);};