Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alt

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alt - npm Package Compare versions

Comparing version 0.15.1 to 0.15.2

12

CHANGELOG.md
# Changelog
## 0.15.2
Added/Fixed:
* AltContainer can now receive new props and it'll change. [commit](https://github.com/goatslacker/alt/commit/07debf2)
## 0.15.1
Fixed:
* A bug with `AltContainer` where it was using ES6 syntax. [commit](https://github.com/goatslacker/alt/commit/accea51)
## 0.15.0

@@ -4,0 +16,0 @@

44

components/AltContainer.js

@@ -56,12 +56,26 @@ /**

return this.getStateFromStores() || {}
return this.getStateFromStores(this.props) || {}
},
componentWillReceiveProps: function (nextProps) {
this.destroySubscriptions()
this.setState(this.getStateFromStores(nextProps))
this.registerStores(nextProps)
},
componentDidMount: function () {
this.registerStores(this.props)
},
componentWillUnmount: function () {
this.destroySubscriptions()
},
registerStores: function (props) {
Subscribe.create(this)
if (this.props.store) {
this.addSubscription(this.props.store)
} else if (this.props.stores) {
var stores = this.props.stores
if (props.store) {
this.addSubscription(props.store)
} else if (props.stores) {
var stores = props.stores

@@ -80,11 +94,11 @@ if (Array.isArray(stores)) {

componentWillUnmount: function () {
destroySubscriptions: function () {
Subscribe.destroy(this)
},
getStateFromStores: function () {
if (this.props.store) {
return getState(this.props.store, this.props)
} else if (this.props.stores) {
var stores = this.props.stores
getStateFromStores: function (props) {
if (props.store) {
return getState(props.store, props)
} else if (props.stores) {
var stores = props.stores

@@ -94,3 +108,3 @@ // If you pass in an array of stores the state is merged together.

return stores.reduce(function (obj, store) {
return assign(obj, getState(store, this.props))
return assign(obj, getState(store, props))
}.bind(this), {})

@@ -101,3 +115,3 @@

return Object.keys(stores).reduce(function (obj, key) {
obj[key] = getState(stores[key], this.props)
obj[key] = getState(stores[key], props)
return obj

@@ -111,3 +125,3 @@ }.bind(this), {})

addSubscription: function(store) {
addSubscription: function (store) {
if (typeof store === 'object') {

@@ -119,3 +133,3 @@ Subscribe.add(this, store, this.altSetState)

altSetState: function () {
this.setState(this.getStateFromStores())
this.setState(this.getStateFromStores(this.props))
},

@@ -122,0 +136,0 @@

{
"name": "alt",
"version": "0.15.1",
"version": "0.15.2",
"description": "A flux implementation",

@@ -19,3 +19,3 @@ "main": "dist/alt.js",

"envify": "^3.4.0",
"eslint": "^0.17.1",
"eslint": "^0.18.0",
"iso": "^4.0.2",

@@ -22,0 +22,0 @@ "istanbul": "^0.3.5",

@@ -375,3 +375,33 @@ import Alt from '../dist/alt-with-runtime'

},
'changing an already mounted components props'() {
let cb = null
const El = React.createClass({
getInitialState() {
return { store: TestStore }
},
componentDidMount() {
cb = state => this.setState(state)
},
render() {
return (
<AltContainer ref="test" store={this.state.store}>
<span />
</AltContainer>
)
}
})
const node = TestUtils.renderIntoDocument(<El />)
assert(node.refs.test.props.store === TestStore, 'node gets first state')
cb({ store: Store2 })
assert(node.refs.test.props.store === Store2, 'node changes props properly')
},
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc