How to extend state in SPA?
See original GitHub issueI have just created the basic SPA by doing npx apprun --init --spa
. Now I want the app’s state to take care of more than just the component name (Home, About, Contact). I may e.g. want to have a counter (+1/-1) on one of the components. In the basic SPA one gets the impression that the component name is the app’s state (state = 'Home';
), but right now it seems that it’s not necessarily so. I’m a bit confused.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Medicaid State Plan Amendments
States also submit SPAs to request permissible program changes, make corrections, or update their Medicaid or CHIP state plan with new ...
Read more >State Plan Amendment (SPA) | SC DHHS
1, 2023, SCDHHS will amend the South Carolina Title XIX state plan to increase the reimbursement rates for the State Plan covered dental...
Read more >Disaster relief state plan amendments - MACPAC
States can submit Medicaid disaster relief state plan amendments (SPAs) to simplify the beneficiary enrollment and renewal process such as expanding use of ......
Read more >Appearance Enhancement Business | Department of State
Under the 'Action' column, click on 'Renew Application', complete the renewal application, including uploading any documentation you are instructed to provide. ...
Read more >Advancing Postpartum Coverage in Medicaid: Waiver or SPA?
Numerous states have requested section 1115 waivers to extend postpartum coverage for different lengths of time (i.e. six months in the case ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is unclear in the documentation that the mounted lifecycle function is only called in the statefull child component.
However, you can pass the initial state in to the component’s constructor directly:
I would suggest creating a module, e.g. global.ts
And import it in main.tsx and other components
You can also export a function for updating the global state in global.ts
To call the function, import it:
If you want to notify other components, send a global event in the set_global_state function:
Other components can subscribe to the events and merge the global state into the local state: