Comments (6)
How would one get access to the flux instance in the base component then? Sometimes you want it and you've removed the fluxMixin
that used to put it on this.flux
. FluxComponent
has the render
override that gets flux that you could use to customize how the wrapped component is rendered, but that doesn't make sense for connect
, which is probably often going to be used as a decorator. I mean sure you could manually pull it out of context
but that seems less than optimal.
Also the comment in FluxComponent.js
still says it injects flux into the children's props, so that should be fixed if it's no longer the case...
from flummox.
(Actually reading the code I'm not sure I see where flux is injected into connect
's base component anyway, so this may not be a change in behavior at all...)
from flummox.
@bdowning FluxComponent
does not pass flux
to the render
method anymore. If you check here you will see that the flux
prop is excluded from the props that get passed to render
or to a wrapped child.
You're right about the comment, I'll get that fixed!
As you said, the solution is to pull it from context
if you really require it. By being able to inject actions into your components now, I'm not sure in which case you would really want it.
As for connect
, the flux
prop gets injected here because we are just spreading all props to the wrapped component.
from flummox.
But how does flux
get on the props
of the connect
wrapper component to be passed to the base component on the line you mention? The connect
wrapper calls this.initialize
which sets this.flux
on the wrapper component, but I'm not seeing anywhere it assigns flux
to its props
. It looks to me like flux
will be passed to the base component if and only if it was passed as a prop to the wrapper. Seems like if it's pulled from context instead (as is probably typically the case) it will be absent.
from flummox.
@bdowning I noticed this because I have a connected component as a root component - which receives the flux
prop because I'm passing it in. We should be consistent here. If the FluxComponent
does not pass it to its children, then connect
should not pass it to the base component either.
from flummox.
FluxComponent
is clearly visually a wrapper, so having it throw away props males sense. But when class Foo
uses connect
as a decorator (which sort of implies a fancy class even though it is a HoC under the hood) I think its a bit surprising that some props that you pass to Foo
don't actually make it there.
But then it also doesn't get wrapped statics currently either, so it's hardly transparent.
Personally I'm not sold on the use-HoCs-for-all-the-things mentality and am sort of sad that mixins have fallen out of favor (and fluxMixin in particular has gone away, even though createClass has not) but I acknowledge that I seem to be in the minority here. (Then again I like Common Lisp and CLOS, who's predecessor arguably created the concept in the first place! :). Certainly, though, working with react-router seemed to be a lot easier and more consistent with mixins than with HoCs. But I can always maintain my own fluxMixin if I get desperate.
from flummox.
Related Issues (20)
- how to get a child component input value HOT 1
- Missing getActionsAsObject from Actions HOT 5
- Incorrect params passed to async begin handler HOT 1
- More topic guides needed in doc HOT 1
- Context differs problem
- Use Redux HOT 6
- Explanation in README as to why a switch to Redux should be made HOT 5
- Import flummox/component fails with 4.0.0-rc1 HOT 1
- unable to make flummox work with react-router 1.0.0-beta3 HOT 2
- Actions.js grabs all console logs HOT 4
- Wrong link in why-flux-component-is-better-than-flux-mixin.md
- Considering the numbers HOT 1
- Support for React 0.14 HOT 17
- How to only use custom stateGetter for subset of subscribed stores HOT 1
- Maintain module? HOT 4
- FluxComponent does not work on IE10 HOT 24
- Flummox 3.6 is incompatible with IE8 HOT 3
- TestUtils removed from NPM HOT 2
- Deprecation warning with React 15.5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flummox.