We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修改代码热更新后点击按钮,状态不会更新,不清楚是什么原因
"dependencies": { "@craco/craco": "^5.7.0", "hox": "^1.1.2", "node-sass": "^4.14.1", "react": "^17.0.1", "react-dom": "^17.0.1", "react-router-dom": "^5.2.0", "react-scripts": "4.0.0", "simple-progress-webpack-plugin": "^1.1.2", "web-vitals": "^0.2.4" },
import { useState } from 'react' import { createModel } from 'hox' function useToken() { const [token, setToken] = useState(''); const changeToken = (payload) => setToken(payload.token); return { token, changeToken } } export default createModel(useToken);
组件中
import React, { memo, useState } from 'react' import useToken from './usetoken' export default memo(function Home() { const token = useToken(); const changeToken = () => token.changeToken({ token: '#123456abc' }) const clearToken = () => token.changeToken({ token: '' }) return ( <div> <p>token: {token.token}</p> <button onClick={changeToken}>设置token</button> <button onClick={clearToken}>清空token</button> </div> ) })
The text was updated successfully, but these errors were encountered:
同样遇到这个问题,有人看吗
Sorry, something went wrong.
No branches or pull requests
修改代码热更新后点击按钮,状态不会更新,不清楚是什么原因
组件中
The text was updated successfully, but these errors were encountered: