Comments (4)
As Bill said. Inside an action, let's call it reset return an empty object {}
.
// action.js
export function resetState() {
return initialState
}
// component.js
const { state, action } = useStateMachine(resetState)
// Call reset
action({})
Because of TypeScript you must pass something. Calling action()
will not pass TS lint, but if you don't use TS you can do it.
from little-state-machine.
As Bill said. Inside an action, let's call it reset return an empty object
{}
.// action.js export function resetState() { return initialState } // component.js const { state, action } = useStateMachine(resetState) // Call reset action({})Because of TypeScript you must pass something. Calling
action()
will not pass TS lint, but if you don't use TS you can do it.
Thanks @ilicmarko for helping ❤️
from little-state-machine.
you should create an action
and return your empty state.
from little-state-machine.
from little-state-machine.
Related Issues (20)
- Does `useStateMachine` trigger re-renders when an update occurs in another component tree? HOT 5
- unable to create mock provider for Jest+React testing Lib HOT 6
- unable to clear store HOT 3
- Help with the LocalStorage and Next.JS HOT 1
- Bf a /:/66 HOT 1
- npm ERR! code ERESOLVE HOT 1
- How to push data to an array state machine HOT 2
- Code Sample in TS is not working correctly HOT 4
- Reset store to initial value ? HOT 1
- Catching Storage error HOT 1
- Error when using with next.js HOT 1
- state not up to date HOT 3
- how to get the global state value outside of the component. HOT 1
- Setting up testing patterns for LSM (React Testing Lib + Jest) - LSM returns empty object in JSDOM HOT 1
- Access the CreateStore Outside a React Component HOT 1
- Dynamically set store name with data from backend HOT 1
- Changing schema of state - guidance on versioning/migrations?
- Type Error for actions without a payload.
- List of Contributors to be present in the Readme HOT 2
- How to use LSM in Next.js 14 (app router)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from little-state-machine.