我是“git”系统的新手。我可能犯了一个错误并将我所有的本地文件集成到“git”系统中。
当我说给我以下错误时,我使用“vs 代码编辑器”并丢弃所有更改:Git: fatal: You are on a branch yet to be born.
这是我在终端中使用“git status”命令时的样子:
warning: could not open directory '.Trash/': Operation not permitted
On branch master
No commits yet
Untracked files:
(use "git add <file>..."
to include in what will be committed)
.. / .npm /
.. / .viminfo
.. / .vscode /
.. / .zsh_history
.. / Applications /
. /
.. / Documents /
.. / Downloads /
.. / Library /
.. / Movies …Run Code Online (Sandbox Code Playgroud) 尝试学习如何使用react hooks。我使用createContext并且我想将状态和函数一起传输到其他组件,但我需要有关如何执行此操作的帮助。我也想问这样做是否有意义。
事实上,我可以通过在我的情况下使用setState来更新状态,但是通过在上下文中定义一个函数,我认为在任何地方使用这个函数更有意义。我错了吗 ?
我的背景是:
export const ExpenseContext = createContext();
export const ExpenseProvider = props => {
const [expense, setExpense] = useState(initialExpenses)
const clearItems = () => {
setExpense([])
}
return ( <
ExpenseContext.Provider value = {
[expense, setExpense],
clearItems
} > {
props.children
} <
/ExpenseContext.Provider>
)
}Run Code Online (Sandbox Code Playgroud)
我想使用这个功能的组件:
const ExpenseList = () => {
const [expense, setExpense] = useContext(ExpenseContext);
const {
clearItem
} = useContext(ExpenseContext);
// const clearItems = () => { …Run Code Online (Sandbox Code Playgroud)