Skip to content

Instantly share code, notes, and snippets.

View OtayNacef's full-sized avatar
🏠

Nacef Otay OtayNacef

🏠
View GitHub Profile
@OtayNacef
OtayNacef / package.json
Created March 7, 2021 21:05
React without CRA
{
"name": "react-without-cra",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack serve --config ./webpack.config.js --mode development --port 3000"
},
"keywords": [],
"author": "",
const webpack = require("webpack");
const path = require("path");
module.exports = {
entry: path.resolve(__dirname, "./src/index.js"),
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
@OtayNacef
OtayNacef / index.js
Last active March 7, 2021 20:36
React App without CRA
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("app"));
// hot reloading. It works by replacing a module of the application
// during runtime with an updated one so that it’s available for instant use.
module.hot.accept();
import React from 'react'
const App = () => {
return (
<h1>
Create React App Without CRA ☘️
</h1>
)
}
@OtayNacef
OtayNacef / isCached
Created February 21, 2021 19:34
Express middleware caching
import { Response, Request, NextFunction } from 'express';
import * as redis from 'redis';
const portRedis = process.env.PORT_REDIS || '6379';
const redisClient = redis.createClient(portRedis);
const isCached = (req: Request, res: Response, next: NextFunction) => {
const { idUser } = req.params;
import react, { ChangeEvent, FC, useState } from "react";
import styled from "styled-components";
import { FaArrowDown } from "@react-icons/all-files/fa/FaArrowDown";
import {
AutoCompleteContainer,
AutoCompleteIcon,
Input,
AutoCompleteItem,
AutoCompleteItemButton
import { ChangeEvent, FC, useState } from "react";
import data from "./data.json";
import styled from "styled-components";
import { FaArrowDown } from "@react-icons/all-files/fa/FaArrowDown";
import {
AutoCompleteContainer,
AutoCompleteIcon,
Input,
AutoCompleteItem,
@OtayNacef
OtayNacef / Pagination.js
Last active February 7, 2021 19:53
React Hooks Pagination
import React, { useState, useEffect } from "react";
const LEFT_PAGE = "LEFT";
const RIGHT_PAGE = "RIGHT";
const range = (from, to, step = 1) => {
let i = from;
const range = [];
while (i <= to) {
range.push(i);
i += step;