react-komposer | Feed data into React components by composing containers | State Container library
kandi X-RAY | react-komposer Summary
kandi X-RAY | react-komposer Summary
Feed data into React components by composing containers. (Works with any kind of data store whether it's Redux, Promises, RxJX, MobX or anything else).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Composes a child loader
- A container .
- Copies the static references to the React component .
- Merge components .
- Sets defaults .
- interpolate default module
react-komposer Key Features
react-komposer Examples and Code Snippets
Community Discussions
Trending Discussions on react-komposer
QUESTION
tl;dr I would like to know where to place context specific multi-step async callback logic in a redux architecture, and if I am on the right track with the example code I supply below. By "multi-step" and "context specific" I typically mean server calls initiated by some user action (onClicks, etc) where the logic might only be relevant for a given component (such as redirect to a given route when successful).
The redux docs has this to say on code with side effects:
In general, Redux suggests that code with side effects should be part of the action creation process. While that logic can be performed inside of a UI component, it generally makes sense to extract that logic into a reusable function so that the same logic can be called from multiple places—in other words, an action creator function.
While that seems fine, I am not totally sure whether it is "correct" to put calls to my routing component in there, as these action creators usually seem quite generic, and triggering routing to some other resource in the app is usually quite context dependant.
I also find it a bit weird to put these quite-different beasts, that trigger action creators asynchronously and dispatch the resulting actions, in the same files (foo-model/actions.js
) as the "clean" sync action creators. Is this the right place? When reading tutorials on Redux it seems like they live side by side.
The example code is quite simple and basically describes these steps:
- On a user click, call a function with some param
- This function calls another async function (such as a network call)
- When the async call completes, trigger a routing action to another page
Background: I want to gradually refactoring a Meteor project by moving all Meteor specific bits out of the React components, eventually substituting Meteor in the front and back for something else. As there are about 50KLOC I cannot do this in one go, so I am gradually working my way through one route at a time, hoping to end up with a standard React+Redux+ReduxRouter package. In the current code routing, data fetching, and rendering is somewhat intertwined in each component, and I am having some trouble finding out where to put multi-step async logic, such as the example below.
Details on the stack I am trying to wrangle my way out of:
- FlowRouter for routing
- Meteor/MiniMongo for data mutation and retrieval
- React Komposer for Higher Order Components
old Meteor code in MyContainerComponent
...ANSWER
Answered 2017-Jun-01 at 10:25In my experience with Redux, I haven't found any problems with putting async calls inside action creators. I think redux-thunk
or some other middleware is very helpful, even for a simple setup.
The only thing I'd add is that I don't find your sample code very readable.
Personally I've come to like the ducks pattern, but also just keeping action types, action creators and reducers in separate files would work to improve clarity.
Hope this helps.
QUESTION
I'm currently using themeteorchef/base boilerplate project. It's been really helpful as I move from the Meteor/Blaze to Meteor/React world.
It's straight forward to pass subscription data to components via containers. But, trying to create a basic profile page has been surprisingly hard and I feel like I'm missing something simple. So far I've managed to pass the user object as a json string (which is not ideal).
My question is- what is the best way to pass a logged in user's info to a react component?
In my container, I have...
...ANSWER
Answered 2017-Apr-24 at 15:36In fact, you can access "Meteor.user()" anywhere, so you don't need to pass it from either Composer or Parent-Component. Therefore, in your simple component, you may use:
QUESTION
I have a React Component Post:
...ANSWER
Answered 2017-Feb-08 at 08:48You could use componentWillReceiveProps
to get new properties and set as component state. This function will run whenever there are new properties passed to component:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-komposer
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page