Skip to content

Instantly share code, notes, and snippets.

View mehmetyilmaz001's full-sized avatar
🎯
Focusing

Mehmet Yılmaz mehmetyilmaz001

🎯
Focusing
View GitHub Profile
@mehmetyilmaz001
mehmetyilmaz001 / ImageScaled.tsx
Created September 19, 2023 07:39
NextJS Scaled Image
<Image
src={imgUrl}
alt={title!}
width={0}
height={0}
sizes="100vw"
style={{ width: '100%', height: 'auto' }}
/>
@mehmetyilmaz001
mehmetyilmaz001 / .eslintrc.json
Created September 17, 2023 12:20
Eslint Sample Config
{
// Configuration for JavaScript files
"extends": [
"airbnb-base",
"next/core-web-vitals", // Needed to avoid warning in next.js build: 'The Next.js plugin was not detected in your ESLint configuration'
"plugin:prettier/recommended"
],
"ignorePatterns":["**/PocWidget/**"],
"rules": {
"prettier/prettier": [
@mehmetyilmaz001
mehmetyilmaz001 / __name__.hook.ts
Created September 10, 2023 14:45
React Scaffold Files
import { I<%= name %>Props } from './<%= name %>.types';
export const use<%= name %> = (props: I<%= name %>Props) => {
// Logic and hooks go here.
const someValue = 'Hello from hook!';
return {
someValue
};
@mehmetyilmaz001
mehmetyilmaz001 / removeEmptyrows.js
Created May 23, 2022 12:57
Remove empty rows helper function for react grid layout
/**
* Fix layout by removing the empty rows
* @param {array} layout
* @returns array layout
*/
export const _removeEmptyRowsFromLayout = layout => {
// Find the max Y coordinate which an item reached (The last row num)
const maxY = Math.max(...layout.map(i => i.y));
const emptyRows = [];
const {override,fixBabelImports,addLessLoader} = require('customize-cra');
module.exports = override(
fixBabelImports('import',{
libraryName:'antd',
libraryDirectory:'es',
style:true,
}),
addLessLoader({
lessOptions:{
{"plugins": [[
"import",
[{
"libraryName": "antd",
"style": "css"
}]
]]}
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
},
npm i less less-loader react-app-rewired babel-plugin-import customize-cra
const isInitialMount = useRef(true);
const createQuestionRes = useSelector( s => s.dialog.createQuestionRes);
useEffect(() => {
if(isInitialMount.current){
isInitialMount.current = false;
}else{ // Trigger useEffect only on update (no in did mount)
if(_.has(createQuestionRes, 'hasError') && !createQuestionRes.hasError){
history.push(getMenuItem('QA').path);
}
useEffect(() => {
if(_.has(createQuestionRes, 'hasError') && !createQuestionRes.hasError){
history.push(getMenuItem('QA').path);
}
}, [createQuestionRes]);