iam4x / connect-alt Goto Github PK
View Code? Open in Web Editor NEWDecorator for passing alt store state through props, heavily inspired from `react-redux::connect`
Decorator for passing alt store state through props, heavily inspired from `react-redux::connect`
Me again! Just a quick one... ๐
Before, when you were using flux.takeSnapshot()
, the store's data was being serialized, which was useful when, for example, using alt's immutable store decorator.
Is it possible to have the new takeSnapshot
serialize the store's data, also?
Hi again!
I've been playing around with using react-router
onEnter
hook to fetch async data from the next component/page if needed. I sort of had this working before by doing something like:
const { component } = nextState.routes[1];
if (typeof component.fetchData === 'function') {
// ... trigger fetchData and then listen to requests store changes
}
I am not sure how to go about this as the component that react-router
now provides is the ConnectToStoresWrapper
. Any ideas?
This line seems to be breaking things on Safari (Version 9.0 (11601.1.56)) and iOS Safari (latest), but only when running in production mode. No idea why.
It seems that accessing DecoratedComponent[prop]
will throw a TypeError
for certain properties (e.g. there is one called 'arguments'). Adding a try/catch block round the if statement this seems to prevent the error...
The error completely stops the app from bootstrapping on the client.
It would be good if you could do connect((state, props) => ({...})
. Having access to props
at connect
can be handy if you need to derive some data based on both state
and props
.
upgrade from 1.0.7 to 1.1.3
dist folder is empty in npm_modules/connect-alt/dist
import connect from 'connect-alt'
fails complaining that connect-alt is not found
import connect from 'connect-alt/src/main.js'
works fine
Hi will this work with react-native.
Thanks in advance.
:0)
A part of my application wasn't rendering. I realized this was because pure rendering kicked in. I had a case like this:
@connect('lanes')
export default class App extends React.Component {...}
...
@connect('notes')
export default class Lane extends React.Component {...}
The idea is that the latter component relies indirectly on lanes
(contains lane ids against which to filter using those notes). Since it's indirect and I pass just lane ids to Lane
, notes
weren't changed and it didn't render. I managed to hack around this by attaching another @connect
to Lane
but that feels a little wrong way to deal with it.
Is there a way to call the methods which stores expose by the way? Looks like connect
gives access only to data.
Example:
@connect(({notes}) => ({notes}), {
noteActions: NoteActions,
laneActions: LaneActions
})
Demo implementation:
import React from 'react';
import connect from 'connect-alt';
const connectAdapter = (Component, state, actions) => {
return class ConnectAdapter extends React.Component {
render() {
return <Component {...Object.assign({}, this.props, actions)} {...this.state} />;
}
};
};
export default (state, actions) => {
return (target) => connect(state)(connectAdapter(target, state, actions));
};
It would be better if connect-alt did this, though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.