[Snyk] Upgrade redux from 0.0.0 to 0.12.0 #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade redux from 0.0.0 to 0.12.0.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 25 versions ahead of your current version.
The recommended version was released on 9 years ago.
Release notes
Package name: redux
No breaking changes this time.
DecoratedComponent
property for easier testinglodash
andbabel-runtime
are droppedcomposeStore
now ignores non-function values (useful in Babel loose mode)@@ INIT
type (might be useful to devtools)Connector
select
property changes, the state did not recalculate (#107)compose
root export tocomposeMiddleware
to clarify the intentgetState
returning stale state after a hot reload (#90)Missing from the 0.10 release notes: React Native is now supported!
(And that's actually a breaking change.)
Now, to import React-specific parts (containers or decorators), you need to either import from
redux/react
orredux/react-native
:import { createRedux, bindActionCreators } from 'redux';
// Import components and decorators from redux/react
import { provide, Connector } from 'redux/react';
// React Native: Import components and decorators from redux/react-native
import { provide, Connector } from 'redux/react-native';
0.10 release also had a problem with ES6 code inside
redux/react
andredux/react-native
entry points, which is now fixed. Please upgrade if you had problems with 0.10.Changes introduced in 0.10.1:
Connector
now throws ifselect
returns something other than a plain object (#85)setState
now returns the state that was actually set. This makes custom dispatchers more composable. (#77)Happy reducing!
Middleware
Redux 1.0 is within striking distance! Can you believe how quickly Redux has matured? @ gaearon made the first commit only 14 days ago.
The 0.10 release is a follow-up to 0.9, with a focus on what we're calling (at least for now) middleware.
You can read all about middleware here. We plan to release some official middleware soon, but of course we'd also love to see middleware created by the community.
Breaking changes
Just a small one: Redux includes a feature that enables you to return a function from an action creator to perform asynchronous dispatches. The function receives a callback and
getState()
as parameters. This has behavior has been re-implemented as middleware and moved into a separate module calledthunkMiddleware()
. It is included automatically when using thecreateRedux(stores)
shortcut, but not when usingcreateDispatcher()
.Tests
We have tests! Still need to improve coverage in a few areas, but we're currently at ~93%. Not bad! Big thanks to @ emmenko for setting these up.
Internal Refactoring & Custom Dispatchers
This release brings breaking changes necessary to start experimenting with middleware and extensibility (#6, #55). It does not bring any support for middleware per se, but it untangles “Dispatcher” (a function that tells how actions turn into state updates) from “Redux” (an instance holding the current state and managing subscriptions). It is now possible to specify your own Dispatcher if you want to experiment with ideas like middleware, time travel, action creators returning Promises or Observables, etc.
createDispatcher
now returns a function you need to give tocreateRedux
createRedux
is the primary API you'll use for initializationdispatcher
prop, adispatch
function prop is injected by the<Connector>
and@ connect
dispatcher
prop,<Provider>
and@ provide
accept aredux
propdispatcher.getAtom()
, useredux.getState()
dispatcher.setAtom()
, you may pass a secondinitialState
argument tocreateRedux
dispatcher.perfrorm()
ordispatcher.dispatch()
, useredux.dispatch()
bindActions
is renamed tobindActionCreators
and acceptsdispatch
as the second parametercomposeStores
andcreateDispatcher
completely and just usecreateRedux(stores)
as a shortcutHow It Looks Like Now
Initialization
Short Way
This is a shortcut for the most common use case.
import * as stores from '../stores/index';
const redux = createRedux(stores);
export default class App {
render() {
return (
<Provider redux={redux}>
{() =>
<CounterApp />
}
</Provider>
);
}
}
Long Way
This way of writing lets you use compose Stores differently, or even pass a custom Dispatcher function. Its signature is
(initialState, setState) => (action) => ()
.import * as stores from '../stores/index';
// Compose all your Stores into a single Store function with
composeStores
:const store = composeStores(stores);
// Create a default Dispatcher function for your composite Store:
const dispatcher = createDispatcher(store); // You may use your custom function here
// Create a Redux instance using the dispatcher function:
const redux = createRedux(dispatcher);
export default class App {
render() {
return (
<Provider redux={redux}>
{() =>
<CounterApp />
}
</Provider>
);
}
}
Hydration and dehydration
const redux = createRedux(stores);
redux.dispatch(MyActionCreators.doSomething()); // fire action creators to fill the state
const state = redux.getState(); // somehow pass this state to the client
// client
const initialState = window.STATE_FROM_SERVER;
const redux = createRedux(stores, initialState);
Binding actions
import { connect, bindActionCreators } from 'redux';
import Counter from '../components/Counter';
import * as CounterActions from '../actions/CounterActions';
@connect(state => ({
counter: state.counter
}))
export default class CounterApp {
render() {
const { counter, dispatch } = this.props;
return (
<Counter counter={counter}
{...bindActionCreators(CounterActions, dispatch)} />
);
}
}
0.8.1 - 2015-06-06
hydrate()
anddehydrate()
are gone, welcomegetAtom()
andsetAtom()
insteadinitialize()
anddispose()
are added for advanced use casesselect
function now updates theConnector
statedispatch
instead ofperform
is fixedThe Big Rewrite!
This release wouldn't have happened without this @ acdlite's wonderful gist.
New:
composeStores
higher-order Store (seriously.)<Connector select={fn}>
propRead the discussion: #46
state
toread: (Store) => state
(#44)Container -> Injector, @ container -> @ inject, Root -> Dispatcher, @ root -> @ dispatch
(#20)@ container
's second parameter now also accepts theprops
passed to it (#36)<Container />
and<Root />
invoke theirthis.props.children
functions withoutthis.props
contextImportant
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: