- copy the file
commit-msg
to.git/hooks/commit-msg
- make sure your delete the sample file
.git/hooks/commit-msg.sample
- Make commit msg executable.
chmod +x .git/hooks/commit-msg
- Edit
commit-msg
to better fit your development branch, commit regex and error message - Profit $$
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
branch="$(git rev-parse - abbrev-ref HEAD)" | |
# a branch name where you want to prevent git push. In this case, it's "master" | |
if [ "$branch" = "master" ]; then | |
echo "You can't commit directly to '"${branch}"' branch" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .huskyrc | |
{ | |
"hooks": { | |
"pre-commit": "echo \"Hello, pre-commit hook!\"" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect, useState} from 'react'; | |
function Counter() { | |
const [counter, setCounter] = useState(0); | |
useEffect(() => { | |
console.log("This useEffect runs on every change"); | |
}) | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect} from 'react'; | |
import ChatAPI from './ChatAPI'; | |
function ChatComponent() { | |
useEffect(() => { | |
ChatAPI.subscribe(); | |
return () => { | |
ChatAPI.unsubscribe(); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect, useState} from "react"; | |
import Counter from "./Counter"; | |
function ConditionalEffects() { | |
const [firstCounter, setFirstCounter] = useState(0); | |
const [secondCounter, setSecondCounter] = useState(0); | |
useEffect(() => { | |
console.log("updated first counter") | |
}, [firstCounter]); | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect, useState} from "react"; | |
import Counter from "./Counter"; | |
function ConditionalEffects() { | |
const [firstCounter, setFirstCounter] = useState(0); | |
const [secondCounter, setSecondCounter] = useState(0); | |
useEffect(() => { | |
console.log("updated first counter") | |
}, [firstCounter]); | |
useEffect(() => { | |
console.log("updated first counter") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect} from 'react'; | |
function OneRun() { | |
useEffect(() => { | |
console.log("Runs only once.") | |
}, []); | |
return <div>One run</div> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UserContext.js | |
import {createContext} from "react"; | |
const user = {}; | |
export default createContext(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UserContext from '../UserContext' | |
import ContextChild from "../ContextChild"; | |
function ContextParent() { | |
const value = {name: "Peter"}; | |
return ( | |
<UserContext.Provider value={value}> | |
<div>context parent</div> | |
<ContextChild/> |
OlderNewer