<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gurupal Singh</title>
    <description>The latest articles on DEV Community by Gurupal Singh (@gurupal).</description>
    <link>https://dev.to/gurupal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F38408%2F1b6acea1-690f-40b8-85d6-15705e8de35e.jpeg</url>
      <title>DEV Community: Gurupal Singh</title>
      <link>https://dev.to/gurupal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gurupal"/>
    <language>en</language>
    <item>
      <title>Add dark mode in react admin panel</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Tue, 17 May 2022 12:48:29 +0000</pubDate>
      <link>https://dev.to/gurupal/add-dark-mode-in-react-admin-panel-with-toggle-6no</link>
      <guid>https://dev.to/gurupal/add-dark-mode-in-react-admin-panel-with-toggle-6no</guid>
      <description>&lt;p&gt;Hi, i am implementing a bootstrap theme to my react admin panel which is having dark mode. I want to add this into my project with prefers-color-scheme (window.matchMedia) and not by toggling. I have 2 bootstrap css files (theme-light.css and theme-dark.css). &lt;/p&gt;

&lt;p&gt;Can anyone help me or have an example that how can i implement the dark mode inside my react application ? I have googled and found below code, but it is not working as expected.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const [isDarkMode, setisDarkMode] = useState(false);&lt;br&gt;
 const [isLightMode, setisLightMode] = useState(false);&lt;br&gt;
 const [supportsColorScheme, setSupportsColorScheme] = useState(false);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
useEffect(() =&amp;gt; {&lt;br&gt;
    const supportsColorScheme = window.matchMedia(&lt;br&gt;
      "(prefers-color-scheme)"&lt;br&gt;
    ).matches;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const isDarkMode = window.matchMedia(
  "(prefers-color-scheme: dark)"
).matches;

const isLightMode = window.matchMedia(
  "(prefers-color-scheme: light)"
).matches;

setisDarkMode(isDarkMode);
setisLightMode(isLightMode);
setSupportsColorScheme(supportsColorScheme);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}, []);&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if (supportsColorScheme) {&lt;br&gt;
    if (isDarkMode) {&lt;br&gt;
      require("assets/css/theme-dark.css");&lt;br&gt;
    } else if (isLightMode) {&lt;br&gt;
      require("assets/css/theme-light.css");&lt;br&gt;
    }&lt;br&gt;
  }&lt;/code&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>darkmode</category>
      <category>javascript</category>
    </item>
    <item>
      <title>send json body in react useQuery ..!!</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Wed, 15 Dec 2021 12:00:03 +0000</pubDate>
      <link>https://dev.to/gurupal/send-json-body-in-react-usequery--4p5h</link>
      <guid>https://dev.to/gurupal/send-json-body-in-react-usequery--4p5h</guid>
      <description>&lt;p&gt;Hi, is there any way to send json body in GET request of react useQuery ?&lt;/p&gt;

&lt;p&gt;for example i want to send below id in json body :-&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
  "id": 21 &lt;br&gt;
 }&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>reactquery</category>
    </item>
    <item>
      <title>Router.back() won't work in incognito mode or when link comes from different source..!!</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Fri, 10 Sep 2021 06:24:48 +0000</pubDate>
      <link>https://dev.to/gurupal/router-back-won-t-work-in-incognito-mode-or-when-link-comes-from-different-source-3abm</link>
      <guid>https://dev.to/gurupal/router-back-won-t-work-in-incognito-mode-or-when-link-comes-from-different-source-3abm</guid>
      <description>&lt;p&gt;Hi, i am using nextjs as react framework for my ecommerce website. My product detail page have an custom back button which is having Router.back() function. This works normal when browsing back and forth in website. But whenever i copy the product detail link and open directly in incognito mode the custom back button won't work...!!&lt;/p&gt;

&lt;p&gt;Anyone have solution for this ?&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>route</category>
      <category>history</category>
    </item>
    <item>
      <title>Toggle state changed on routing..!!</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Mon, 23 Aug 2021 14:20:10 +0000</pubDate>
      <link>https://dev.to/gurupal/toggle-state-changed-on-routing-35no</link>
      <guid>https://dev.to/gurupal/toggle-state-changed-on-routing-35no</guid>
      <description>&lt;p&gt;Hi, I am building a dashboard with reactjs. I have nested menu in the admin sidebar which is controlled by toggle on parent item. Whenever i click on any of the nested item the toggle items menu get closed. Screenshot attached for the same.&lt;/p&gt;

&lt;p&gt;Anyone, please suggest some solution.&lt;/p&gt;

&lt;p&gt;I am using react router for navigation.&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactrouter</category>
      <category>admin</category>
      <category>dashboard</category>
    </item>
    <item>
      <title>Gatsby build cron issue..!!</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Tue, 03 Aug 2021 06:04:46 +0000</pubDate>
      <link>https://dev.to/gurupal/gatsby-build-cron-issue-bk9</link>
      <guid>https://dev.to/gurupal/gatsby-build-cron-issue-bk9</guid>
      <description>&lt;p&gt;Hi, I am trying to Build static pages for gatsby from a bash script. Bash script is working fine but whenever i try to run it via crontab it throw error for node and npm.&lt;/p&gt;

&lt;p&gt;Node version i am using is v10.13.0 and npm version is v6.4.1. &lt;/p&gt;

&lt;p&gt;But somehow cron log gives me error which shows my node version v8.10.0 and npm version v3.5.2. Screenshot attached for the same.&lt;/p&gt;

&lt;p&gt;Even i do not have node v8 installed on my server. Both on root and ubuntu user. &lt;/p&gt;

&lt;p&gt;Why it is taking node version 8 for cronjob?&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>node</category>
      <category>react</category>
    </item>
    <item>
      <title>Multiple Network Calls on read, write apollo cache</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Tue, 18 May 2021 06:11:59 +0000</pubDate>
      <link>https://dev.to/gurupal/multiple-network-calls-on-read-write-apollo-cache-48h2</link>
      <guid>https://dev.to/gurupal/multiple-network-calls-on-read-write-apollo-cache-48h2</guid>
      <description>&lt;p&gt;Hi, This is the ecommerce project that i am working on. I am using Nextjs framework with Apollo client 3. While doing add to cart mutation i am using read and write Apollo cache function to update the total items in the cart, but some how it is still hitting database when writing to cache. I can see 2 network calls that is - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For AddToCart mutation which is perfectly fine.&lt;/li&gt;
&lt;li&gt;For Cart Query (which is i think wrong), as i could have directly use refetchQuery function to do the same.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useQuery, useMutation } from "@apollo/client";
import cookie from "react-cookies";

import {
  ALLCATEGORIES,
  SUBCATEGORIES,
  CART_QUERY,
  SESSIONID,
} from "apollo/queries";

import { CART_MUTATION } from "apollo/mutations";

var sessionid = cookie.load("sessionid");
var token = localStorage.getItem('auth');

export const useGetCategories = () =&amp;gt; useQuery(ALLCATEGORIES);
export const useGetSessionId = () =&amp;gt; useQuery(SESSIONID);
export const useCart = (options) =&amp;gt; useQuery(CART_QUERY, options);
export const useProductListing = (options) =&amp;gt; useQuery(SUBCATEGORIES, options);

export const useAddToCart = () =&amp;gt;
  useMutation(CART_MUTATION, {
    update(cache, { data: { addToCart } }) {
      try {
        const data = cache.readQuery({
          query: CART_QUERY,
          variables: {
            sessionId: sessionid,
            token: token,
          },
        });
        cache.writeQuery({
          query: CART_QUERY,
          variables: {
            sessionId: sessionid,
            token: token,
          },
          data: {
            cart: [data.cart, addToCart],
          },
        });
      } catch (error) {
        console.log("error", error);
      }
    },
  });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import styled from "styled-components";
import Rup from "../../icons/rupee.svg";
import ProductImage from "public/product.png";
import { fontWeight, flexbox, fontSize } from "@/styles/global-styles";
import { LazyLoadImage } from "react-lazy-load-image-component";
import { useAddToCart } from "apollo/actions";
import cookie from "react-cookies";
import Loading from "@/components/loader";

const Products = ({ products }) =&amp;gt; {
  var sessionid = cookie.load("sessionid");
  const [addToCart, { loading }] = useAddToCart();

  const handleAddToCart = async (uuid) =&amp;gt; {
    await addToCart({
      variables: {
        sessionId: sessionid,
        product: uuid,
        quantity: 1,
        monogram: "",
        monogramType: "",
      },
    });
  };

  if (loading) return &amp;lt;Loading /&amp;gt;;

  return (
    &amp;lt;&amp;gt;
      &amp;lt;ProductContainer&amp;gt;
        {products.map((product, index) =&amp;gt; {
          return (
            &amp;lt;ProductCard key={index}&amp;gt;
              &amp;lt;Badge&amp;gt;Our Bestseller&amp;lt;/Badge&amp;gt;
              &amp;lt;ProductThumb&amp;gt;
                &amp;lt;LazyLoadImage src={ProductImage} height={436} effect="blur" /&amp;gt;
              &amp;lt;/ProductThumb&amp;gt;
              &amp;lt;ProductDetails&amp;gt;
                &amp;lt;ProductName&amp;gt;{product.name}&amp;lt;/ProductName&amp;gt;
                &amp;lt;Subtitle&amp;gt;{product.subtitle}&amp;lt;/Subtitle&amp;gt;
                &amp;lt;PriceContainer&amp;gt;
                  &amp;lt;Price&amp;gt;
                    &amp;lt;Rup /&amp;gt;
                    &amp;lt;span&amp;gt;{product.specialPrice}&amp;lt;/span&amp;gt;
                    {product.specialPrice != product.price ? (
                      &amp;lt;CrossPrice&amp;gt;{product.price}&amp;lt;/CrossPrice&amp;gt;
                    ) : (
                      &amp;lt;&amp;gt;&amp;lt;/&amp;gt;
                    )}
                  &amp;lt;/Price&amp;gt;
                  &amp;lt;Button onClick={() =&amp;gt; handleAddToCart(product.uuid)}&amp;gt;
                    add to cart
                  &amp;lt;/Button&amp;gt;
                &amp;lt;/PriceContainer&amp;gt;
              &amp;lt;/ProductDetails&amp;gt;
            &amp;lt;/ProductCard&amp;gt;
          );
        })}
      &amp;lt;/ProductContainer&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default Products;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Is there something wrong i am doing ? Need help please &lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>hooks</category>
      <category>apollo</category>
      <category>javascript</category>
    </item>
    <item>
      <title>browser back button takes to bottom of the page instead of previous location</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Wed, 10 Mar 2021 09:33:05 +0000</pubDate>
      <link>https://dev.to/gurupal/browser-back-button-takes-to-bottom-of-the-page-instead-of-previous-location-3bn6</link>
      <guid>https://dev.to/gurupal/browser-back-button-takes-to-bottom-of-the-page-instead-of-previous-location-3bn6</guid>
      <description>&lt;p&gt;I have one product listing page with infinite scroll pagination. Whenever i click on any of the product and goto product detail page and then press browser back button, it will takes me to bottom of the page instead of where i was. What should i do to retain by old state ?&lt;/p&gt;

&lt;p&gt;gatsby version 2.19.18&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Animation stop working on conditional rendering ..!!</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Sat, 30 Jan 2021 12:58:16 +0000</pubDate>
      <link>https://dev.to/gurupal/animation-stop-working-on-conditional-rendering-2lol</link>
      <guid>https://dev.to/gurupal/animation-stop-working-on-conditional-rendering-2lol</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Products = ({
  product: { name, displayImage, subtitle, price, uuid, slug },
}) =&amp;gt; {
  const [show, setShow] = useState(false);

  const clickVariants = {
    opened: {
      top: "50vh",
    },
    closed: {
      top: "0vh",
    },
  };

  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="products"&amp;gt;
      &amp;lt;motion.button onClick={() =&amp;gt; setShow((state) =&amp;gt; !state)}&amp;gt;
                Buy
                &amp;lt;/motion.button&amp;gt;
              &amp;lt;/div&amp;gt;
      {show &amp;amp;&amp;amp; (
        &amp;lt;&amp;gt;
          &amp;lt;div
            onClick={() =&amp;gt; setShow((state) =&amp;gt; !state)}
            className="backdrop"
          &amp;gt;&amp;lt;/div&amp;gt;
          &amp;lt;motion.div
            initial={false}
            animate={show ? "opened" : "closed"}
            variants={clickVariants}
            className="modal__container"
          &amp;gt;
            &amp;lt;h1&amp;gt;{name}&amp;lt;/h1&amp;gt;
          &amp;lt;/motion.div&amp;gt;
        &amp;lt;/&amp;gt;
      )}
    &amp;lt;/&amp;gt;
  );
};

export default Products;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Can someone tell me why i am unable to run popup animation while adding condition ? I tried searching it on google but nothing works for me.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>`onClick` listener to be a function, instead got a value of `object` type.</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Sun, 24 Jan 2021 16:50:28 +0000</pubDate>
      <link>https://dev.to/gurupal/onclick-listener-to-be-a-function-instead-got-a-value-of-object-type-og0</link>
      <guid>https://dev.to/gurupal/onclick-listener-to-be-a-function-instead-got-a-value-of-object-type-og0</guid>
      <description>&lt;p&gt;Here is i am checking on my cart page if user is null than open login popup otherwise go directly to Checkout page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; var path;
  if (user !== null) {
    path = "/checkout";
  } else {
    path = "";
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the button on cart page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;button
   type="button"
   onClick={path === "" ? openModal : &amp;lt;&amp;gt;&amp;lt;/&amp;gt;}&amp;gt;
   &amp;lt;Link href={path}&amp;gt;Checkout&amp;lt;/Link&amp;gt;
 &amp;lt;/button&amp;gt;
 &amp;lt;Login showModal={showModal} setShowModal={setShowModal} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But i am getting warnings on console that &lt;code&gt;onClick&lt;/code&gt; listener to be a function, instead got a value of &lt;code&gt;object&lt;/code&gt; type. Modal is opening but how can i fix this warning ?&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Invalid hook call. Hooks can only be called inside of the body of a function component. ?? </title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Sun, 17 Jan 2021 12:56:05 +0000</pubDate>
      <link>https://dev.to/gurupal/invalid-hook-call-hooks-can-only-be-called-inside-of-the-body-of-a-function-component-264j</link>
      <guid>https://dev.to/gurupal/invalid-hook-call-hooks-can-only-be-called-inside-of-the-body-of-a-function-component-264j</guid>
      <description>&lt;p&gt;&lt;strong&gt;store.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yEhQsgBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fcusb73cm3il4gi7jd46.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yEhQsgBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fcusb73cm3il4gi7jd46.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;index.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z1J2xS6r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hv997wqm47e9y0icaa17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z1J2xS6r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hv997wqm47e9y0icaa17.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;package.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tF6SGwvC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tzt7rp27lkjou092j5r1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tF6SGwvC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tzt7rp27lkjou092j5r1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "../styles/style.scss";
import store from "@config/store";
import { Provider } from "react-redux";
import NetworkDetector from "@config/network";
import { ApolloProvider } from "@apollo/client";
import { useApollo } from "@config/apolloClient";

function App({ Component, pageProps }) {
  const apolloClient = useApollo(pageProps.initialApolloState);

  return (
    &amp;lt;ApolloProvider client={apolloClient}&amp;gt;
      &amp;lt;Provider store={store}&amp;gt;
        &amp;lt;Component {...pageProps} /&amp;gt;
      &amp;lt;/Provider&amp;gt;
    &amp;lt;/ApolloProvider&amp;gt;
  );
}

export default NetworkDetector(App);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why i am getting this Invalid hook call in redux dev tools. Am i doing something wrong here ?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Pto2pPn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/et9rrc0zyfry9jzh39ev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Pto2pPn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/et9rrc0zyfry9jzh39ev.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;List Products Action&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RNjVRSwk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o7ajn4o6jb02qxfujjh3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RNjVRSwk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o7ajn4o6jb02qxfujjh3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>redux</category>
      <category>nextjs</category>
      <category>react</category>
    </item>
    <item>
      <title>Data is undefined - Apollo Client ..!!</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Mon, 09 Nov 2020 16:32:20 +0000</pubDate>
      <link>https://dev.to/gurupal/data-is-undefined-apollo-client-30ed</link>
      <guid>https://dev.to/gurupal/data-is-undefined-apollo-client-30ed</guid>
      <description>&lt;p&gt;I am getting data undefined when I goto to localhost:3000:/someslug/&lt;/p&gt;

&lt;p&gt;Is there i am doing something wrong in this ?&lt;/p&gt;

&lt;p&gt;`import React from 'react';&lt;br&gt;
import Layout from "@components/layout";&lt;br&gt;
import Loader from "@components/Loader";&lt;br&gt;
import Products from "@components/Products";&lt;br&gt;
import { useQuery } from "@apollo/react-hooks";&lt;br&gt;
import * as Constants from '../config/constants';&lt;br&gt;
import { withApollo } from '../config/withApollo';&lt;br&gt;
import gql from "graphql-tag";&lt;br&gt;
import styles from '../components/Products/products.module.scss';&lt;/p&gt;

&lt;p&gt;const CATEGORY_QUERY = gqlquery CategoryQuery($slug: String!) { categoryBySlug(slug: $slug) { url slug productCount } };&lt;/p&gt;

&lt;p&gt;const Category = ({ slug }) =&amp;gt; {&lt;br&gt;
const { loading, error, data } = useQuery(CATEGORY_QUERY, {&lt;br&gt;
variables: { slug },&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;console.log(data);&lt;/p&gt;

&lt;p&gt;if (error) return &lt;/p&gt;
&lt;h1&gt;Error&lt;/h1&gt;;&lt;br&gt;
if (loading) return ;&lt;br&gt;
return (&lt;br&gt;
  &lt;br&gt;
    &lt;br&gt;
        {/* {data.allProducts.length&lt;br&gt;
            ? data.allProducts.map(product =&amp;gt; )&lt;br&gt;
            : ""&lt;br&gt;
        } */}&lt;br&gt;
    &lt;br&gt;
  &lt;br&gt;
);&lt;br&gt;
}

&lt;p&gt;export default withApollo({ ssr: true })(Category);`&lt;/p&gt;

</description>
      <category>react</category>
      <category>graphql</category>
    </item>
    <item>
      <title>How to Serve Nodejs Application from sub directory with PHP Application on root?</title>
      <dc:creator>Gurupal Singh</dc:creator>
      <pubDate>Fri, 23 Oct 2020 21:18:33 +0000</pubDate>
      <link>https://dev.to/gurupal/how-to-serve-nodejs-application-from-sub-directory-with-php-application-on-root-38gp</link>
      <guid>https://dev.to/gurupal/how-to-serve-nodejs-application-from-sub-directory-with-php-application-on-root-38gp</guid>
      <description>&lt;p&gt;I have php running in root directory and wants to run a microservice built with nodejs in subdirectory. I did some configurations but the css/js/images are showing 404 not found. Below the nginx configuration.&lt;/p&gt;

&lt;p&gt;server {&lt;br&gt;
        listen 80 default_server;&lt;br&gt;
        listen [::]:80 default_server;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    server_name    www.test.com;
return         301 https://$server_name$request_uri;

    root /var/www/html/app/webroot;

    index index.php index.html index.htm index.nginx-debian.html;


    location / {
    try_files $uri $uri/ /index.php?$args;
    }
location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;server {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;listen  443 ssl http2;
    listen  [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/test_chain.crt;
    ssl_certificate_key /etc/nginx/ssl/www.test.com.key;

root /var/www/html/app/webroot;

    # Add index.php to the list if you are using PHP
    index index.php index.html;

    include snippets/phpmyadmin.conf;

    server_name www.test.com;



# . files
location ~ /\.(?!well-known) {
        deny all;
}

    location / {

try_files $uri $uri/ /index.php?$args;
            }

location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_buffers               8 16k;
    fastcgi_buffer_size           32k;
        }

    #NODEJS SERVER BLOCK
location /public {
       root /var/www/html/newcars/public/;
    }

    location /newcars {
     rewrite ^/newcars/(.*)$ /$1 break;
 proxy_pass http://127.0.0.1:3000;

}
 #END of NODEJS SERVER BLOCK

}

location ^~ /estore {
        root /var/www/html;
        index index.php index.html index.htm;
        try_files $uri $uri/ @opencart;
location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_intercept_errors on;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_buffers               8 16k;
    fastcgi_buffer_size           32k;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

    location ~* (\.(tpl|ini))$
        { deny all; }
}

location @opencart {
    rewrite ^/(.+)$ /estore/index.php?_route_=$1 last;
}

location = /estore/sitemap.xml {
    rewrite ^(.*)$ /estore/index.php?route=extension/feed/google_sitemap break;
}

location = /estore/googlebase.xml {
rewrite ^(.*)$ /estore/index.php?route=extension/feed/google_base break;
}

location /estore/system {
rewrite ^/estore/system/download/(.*) /estore/index.php?route=error/not_found break;
}

location /estore/video {
rewrite ^/estore/video/courses/(.*) /estore/index.php?route=video/courses break;
}

location /estore/courses {
rewrite ^/estore/courses-lists(.*) /estore/index.php?route=course/courseslist break;
}

# favicon.ico
    location = /favicon.ico {
            log_not_found off;
            access_log    off;
    }

    # robots.txt
    location = /robots.txt {
            log_not_found off;
            access_log    off;
    }

    # assets, media
    location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
            expires    7d;
            access_log off;
    }

    # svg, fonts
    location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
            add_header Access-Control-Allow-Origin "*";
            expires    7d;
            access_log off;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

</description>
      <category>node</category>
      <category>nginx</category>
      <category>php</category>
    </item>
  </channel>
</rss>
