- if you manage JavaScript primitives as state
- if you have simple state transitions
- if you want to have business logic within your component
- if you have different properties that don’t change in any correlated manner and can be managed by multiple useState hooks
- if your state is co-located to your component
- if you’ve got a small application (but the lines are blurry here)
--- | |
import Layout from '../../layouts/MainLayout.astro'; | |
import {getLanguageFromFilename, getSlugFromFilename} from '../../languages'; | |
export async function getStaticPaths() { | |
/** | |
* This builds up a set of params using the filename (which is always in english) as the slug, | |
* and adds a redirect prop to the proper internationalized slug. | |
*/ | |
function getRedirects(allPages) { |
9 March, 2019
We were discussing with @erusev what we can do with async operation when using useReducer()
in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer()
. The problem we are facing and don't know how to solve is async operations.
In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.
Note:
When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.
If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:
- Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
Lots of stack traces and error messages for CKAN, followed by a comment about how I fixed it (that time). | |
NB don't email me privately for help - ask on StackOverflow #ckan instead. | |
David | |
File "/vagrant/src/ckan/ckan/templates/home/snippets/search.html", line 1, in top-level template code | |
{% set tags = h.get_facet_items_dict('tags', limit=3) %} | |
File "/vagrant/src/ckan/ckan/lib/helpers.py", line 949, in get_facet_items_dict | |
if not c.search_facets or \ | |
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__ | |
return getattr(self._get_current_object(), name) |
This content moved here: https://exploringjs.com/impatient-js/ch_arrays.html#quickref-arrays
import produce from 'immer'; | |
import {createStore} from 'redux'; | |
const handleActions = (actionsMap, defaultState) => ( | |
state = defaultState, | |
{type, payload} | |
) => | |
produce(state, draft => { | |
const action = actionsMap[type]; | |
action && action(draft, payload); |
Last Updated: 2018-01-23
Status: Draft