React, but with built-in global state management.
reactn/typings/*
directory renamed to reactn/types/*
.package-lock.json
added to the .gitignore
and .npmignore
files, allowing contributors to install with NPM instead of Yarn.yarn upgrade
performed on the repository root and docs
directories (updating their respective yarn.lock
files).Adds a getDispatch
helper function to return all dispatch functions (created from reducers) currently attached to the global state. #73
Allows useDispatch
to be called without any parameters to return all dispatch functions currently attached to the global state.
Since its inception, ReactN has always felt to me to be deeply tied to the community. It is likely the first time I started a project with intense community interviewing before ever writing the first line of code. Each step of the way, I tried to thoroughly document my and developers' thought processes and use cases in the most public ways possible -- GitHub Issues, Medium articles, Reddit threads, and even now a Discord channel on the Reactiflux server.
ReactN spent long enough evolving in v0
that 1.0.0
never even needed so much as a patch.
The first change since launch is a breaking change, so 2.0.0
launched today. I wanted to engage the community with this change.
// Class Component member variables
this.global.property; // -->
this.global.property; // (unchanged)
this.global.reducer('value'); // -->
this.dispatch.reducer('value');
// Function Component hooks
useGlobal('property'); // -->
useGlobal('property'); // (unchanged)
useGlobal('reducer'); // -->
useDispatch('reducer');
useGlobal(function(){ }); // -->
useDispatch(function(){ });
// Previous global reducer:
function reducer(state, arg1, arg2) { }
// Current global reducer:
function reducer(state, dispatch, arg1, arg2) { }
Full TypeScript support. Intellisense has never been so powerful.
Redux DevTools are supported! View your ReactN state and dispatched actions right from developer tools. #41
Ability to type the default global state. (Example) #50
Reducers as sagas, which is why reducers now receive the dispatch object. You can now have a reducer that dispatches other reducers. #62
function addSubtract(state, dispatch, a, s) {
await dispatch.add(a);
await dispatch.subtract(s);
}
Since ReactN serves as both a React-integrated API and a global state, I was thinking it would be a non-breaking change (exact same API; semver 2.1) to change the global state manager to a Redux store. This could improve support for third party tooling (like middleware) while offsetting a lot of testing and maintenance. Just toying with the idea. I don't want the use of Redux to decrease user confidence that boilerplate is eliminated or learning curve is shallow. This would essentially make ReactN an alternative to react-redux
instead of redux
. I'll let the community discuss and focus more on a smooth 2.0 launch for the time being.
Thanks for all the support! 🎉
Provider
Component for managing multiple global states simultaneously. #17Provider
Components for targeting a global state. #37[ state, dispatch ]
destructuring. #42Added addCallback
to execute a function after global state changes. #29
Added getGlobal
helper function for accessing a snapshot of the current global state. #35
Added removeCallback
to remove callbacks added via addCallback
.
Added unit tests for most helper functions.
Ported the singleton global state to a default global state, in preparation for multiple global states via the Context API.
ReferenceError: window is not defined
on server-side applications. #30