Skip to content

Instantly share code, notes, and snippets.

View oguzkaracar's full-sized avatar
🎯
Focusing

Oğuzhan Karaçar oguzkaracar

🎯
Focusing
  • Ankara, Turkey
View GitHub Profile
@oguzkaracar
oguzkaracar / customUseContext.js
Created March 4, 2022 11:30
React Context example usage
import { createContext } from 'react';
import { useContext } from 'react';
// local imports
import routes from './fuse-configs/routesConfig';
/* Create Context */
const AppContext = createContext({});
/* Context Provider */
@oguzkaracar
oguzkaracar / useSafeDispatch
Created January 9, 2022 21:25
Safe dispatch funtion - just dispatch it when component is mounted
const useSafeDispatch = dispatch => {
/* Figure out component is unmounted */
const mountedRef = React.useRef(false)
/* this function going to be called as soon we mounted, without waiting the browser paint the screen */
React.useLayoutEffect(() => {
mountedRef.current = true
/* called when as soon we unmounted without waiting the browser paint the screen */
return () => {
@oguzkaracar
oguzkaracar / slugify.js
Created June 26, 2021 21:43
Convert text to slug
export const convertToSlug = (str) => {
return str
.toUpperCase()
.toLowerCase()
.trim()
.normalize('NFD')
.replace(/[^\w-]+/g, '')
.replace(/\s+/g, '-');
};
@oguzkaracar
oguzkaracar / .prettierrc-config
Last active December 16, 2021 10:47
prettierrc - react-development
{
"arrowParens": "avoid",
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": true,
@oguzkaracar
oguzkaracar / vscode-settings.json
Last active December 16, 2021 10:46
VS Code Settings
{
"editor.fontSize": 15,
"liveServer.settings.donotShowInfoMsg": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"vsintellicode.typescript.completionsEnabled": true,
"javascript.suggest.includeCompletionsForImportStatements": true,
"javascript.suggest.autoImports": true,
"terminal.integrated.defaultProfile.windows": "Git Bash",
"[javascript]": {