title: react-router-dom v6 StaticRouter context is not working
body: <p>I'm trying to make SSR React web application.
  Everything works fine except staticContext.</p>
  <p><strong>My server code is</strong></p>
  <pre><code>// IMPORTS
  
  const renderer = (req, store, context) =&gt; {
      const content = renderToString(
          &lt;Provider store={store}&gt;
              &lt;ThemeProvider theme={responsiveFontSizes(theme)}&gt;
                  &lt;CssBaseline /&gt;
                  &lt;StaticRouter location={req.path} context={context}&gt;
                      &lt;Navigation /&gt;
                      &lt;main&gt;
                          {renderRoutes(MainRouter)}
                      &lt;/main&gt;
                      &lt;Footer /&gt;
                  &lt;/StaticRouter&gt;
              &lt;/ThemeProvider&gt;
          &lt;/Provider&gt;
      );
  
      const helmet = Helmet.renderStatic();
  
      return `
          &lt;!DOCTYPE html&gt;
          &lt;html&gt;
              &lt;head&gt;
                  &lt;meta charset=&quot;utf-8&quot; /&gt;
                  &lt;link rel=&quot;icon&quot; href=&quot;${process.env.REACT_APP_URL}/favicon.ico&quot; /&gt;
                  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;
                  &lt;meta name=&quot;theme-color&quot; content=&quot;${process.env.REACT_APP_THEME_COLOR}&quot; /&gt;
                  ${helmet.title.toString()}
                  ${helmet.meta.toString()}
                  &lt;link rel=&quot;stylesheet&quot; href=&quot;main.css&quot;&gt;
                  &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt;
                  &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt;
                  &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;noscript&gt;Pre dokonalé fungovanie tejto webovej aplikácie povoľte JavaScript.&lt;/noscript&gt;
                  &lt;div id=&quot;root&quot;&gt;${content}&lt;/div&gt;
                  &lt;script&gt;
                      window.INITIAL_STATE = ${serialize(store.getState())}
                  &lt;/script&gt;
                  &lt;script src=&quot;bundle.js&quot;&gt;&lt;/script&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      `;
  };
  
  app.get('*', (req, res) =&gt; {
  
      const store = createStore();
  
      var promises = matchRoutes(MainRouter, req.path).map(route =&gt; {
      return route?.loadData ? route.loadData(store) : [];
      });
  
      promises.push(loadData(store, req.cookies));
  
      Promise.all(promises).then(() =&gt; {
          const context = {};
          const content = renderer(req, store, context);
  
          if(context.url) {
              return res.redirect(302, context.url);
          }
  
          if(context.notFound) {
              console.log('404');
              res.status(404);
          };
  
          res.send(content);
      });
  });
  </code></pre>
  <p><strong>And my client code of 404 component is</strong></p>
  <pre><code>const NotFound = ({ staticContext = {} }) =&gt; {
      staticContext.notFound = true;
  
      const head = () =&gt; (
          &lt;Helmet&gt;
              &lt;title&gt;{process.env.REACT_APP_NAME} – Stránka sa nenašla&lt;/title&gt;
          &lt;/Helmet&gt;
      );
  
      return (
          &lt;React.Fragment&gt;
              {head()}
              &lt;section&gt;
                  {/* Some content */}
              &lt;/section&gt;
          &lt;/React.Fragment&gt;
      )
  };
  
  export default {
      Component: NotFound
  };
  </code></pre>
  <p>This line should pass <strong>notFound = true</strong> argument into the request:</p>
  <pre><code>staticContext.notFound = true;
  </code></pre>
  <p><br />And so this part of code should set request status to 404 and console log '404' string:</p>
  <pre><code>if(context.notFound) {
      console.log('404');
      res.status(404);
  };
  </code></pre>
  <p>But it doesn't work.
  Is it possible that my code is deprecated?
  I'm using currently latest stable versions of all dependencies.</p>
  <p><strong>My package.json dependencies</strong></p>
  <pre><code>&quot;@emotion/react&quot;: &quot;^11.7.1&quot;,
  &quot;@emotion/styled&quot;: &quot;^11.6.0&quot;,
  &quot;@mui/icons-material&quot;: &quot;^5.2.5&quot;,
  &quot;@mui/material&quot;: &quot;^5.2.5&quot;,
  &quot;axios&quot;: &quot;0.24.0&quot;,
  &quot;babel-cli&quot;: &quot;6.26.0&quot;,
  &quot;babel-core&quot;: &quot;6.26.3&quot;,
  &quot;babel-loader&quot;: &quot;8.2.3&quot;,
  &quot;compression&quot;: &quot;1.7.4&quot;,
  &quot;concurrently&quot;: &quot;6.5.1&quot;,
  &quot;cookie-parser&quot;: &quot;^1.4.6&quot;,
  &quot;cors&quot;: &quot;^2.8.5&quot;,
  &quot;date-fns&quot;: &quot;^2.27.0&quot;,
  &quot;express&quot;: &quot;4.17.2&quot;,
  &quot;lodash&quot;: &quot;4.17.21&quot;,
  &quot;nodemon&quot;: &quot;2.0.15&quot;,
  &quot;npm-run-all&quot;: &quot;4.1.5&quot;,
  &quot;react&quot;: &quot;17.0.2&quot;,
  &quot;react-dom&quot;: &quot;17.0.2&quot;,
  &quot;react-helmet&quot;: &quot;6.1.0&quot;,
  &quot;react-redux&quot;: &quot;^7.2.6&quot;,
  &quot;react-router-dom&quot;: &quot;6.2.1&quot;,
  &quot;react-spinners&quot;: &quot;^0.11.0&quot;,
  &quot;redux&quot;: &quot;^4.1.2&quot;,
  &quot;serialize-javascript&quot;: &quot;6.0.0&quot;,
  &quot;universal-cookie&quot;: &quot;^4.0.4&quot;,
  &quot;webpack&quot;: &quot;5.65.0&quot;,
  &quot;webpack-dev-server&quot;: &quot;4.7.1&quot;,
  &quot;webpack-merge&quot;: &quot;5.8.0&quot;,
  &quot;webpack-node-externals&quot;: &quot;3.0.0&quot;
  </code></pre>