hanifrev / error-documentation

My personal error documentation (and the solution of course)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hanifrev's Error Documentation


ReactJS


Javascript Related

  • Get unique value

    [...new Set(a)]
    
    const numbers = [2,3,4,4,2,3,3,4,4,5,5,6,6,7,5,32,3,4,5]
    console.log([...new Set(numbers)]) // [2, 3, 4, 5, 6, 7, 32]
    
  • Scroll to top Use built in javascript function scrollTo()

    https://stackoverflow.com/a/52948533


Vanilla CSS


Tailwind CSS

  • Intellisense

    if not working try to disable, reload, then enable, reload ctrl + space to view

  • Tailwind not working

    check tailwind.config, on purge, usually missing path (src), try this: purge: ['./pages//*.{js,ts,jsx,tsx}','./src/components//*.{js,ts,jsx,tsx}'],


NextJS

  • Import font (custom font)

    customFont={
          <link
            href="https://fonts.googleapis.com/css2?family=Ubuntu&display=swap"
            rel="stylesheet"
          />
        }
    

    Put inside of , then use it {fontFamily: 'font_name'}

  • id="__next" styling

    vercel/next.js#4834

    <Root theme={theme} scheme={scheme} className="overflow">
      	<style>
          {`
        	    #__next { overflow: hidden }
            `}
      	</style>
    ....
    </Root>
    
  • NODE_ENV is not recognized as an internal or external command, operable program or batch file.

    https://github.com/laggingreflex/win-node-env

    npm install -g win-node-env
    
  • if there is error on console.log [forwardRef (container)]

    its means that there is an empty active container, disable the whole container or fill it with something

  • next/image Unconfigured Host

    https://nextjs.org/docs/messages/next-image-unconfigured-host

    Add the hostname of your URL to the images.domains config in next.config.js

    module.exports = {
      images: {
        domains: ['assets.example.com'],
      },
    }
    
  • Dynamic Routing getServerSideProps

    vercel/next.js#13309 > https://stackoverflow.com/questions/61222726/dynamic-routing-with-getserversideprops-in-nextjs/61240697#61240697

    export async function getServerSideProps(context) {
    const { id } = context.query;
    const res = await fetch(`https://restcountries.eu/rest/v2/name/${id}`);
    const country = await res.json();
    
    console.log(`Fetched place: ${country.name}`);
    return { props: { country } };
    
    
  • Data Fetching

    https://stackoverflow.com/a/69075605/11358449

    You can only use getInitialProps, getServerSideProps, getStaticProps in Next.js PAGES folder, these methods will not work outside pages folder

  • Get query string params from URL

    https://stackoverflow.com/a/61969441/11358449

    Use getInitialProps methods,

    const Index = ({id}) => {
    return(<div>{id}</div>)
    }
    
    Index.getInitialProps = async ({ query }) => {
      const {id} = query
    
      return {id}
    }
    

About

My personal error documentation (and the solution of course)


Languages

Language:Shell 100.0%