Comments (5)
I'm not sure exactly if I understood the use-case.
react-resolver
just resolves property if the component does not have it already,- which seems logical to me. If the property is defined already, it should be valid and up to date, if not - let the whole component re-render and fetch the data.
In your example, users
property comes from the redux store, and you want for react-resolver
to fetch the data if there is none. But how do you plan to set the data back to the store?
I'm not sure that mixing redux
and react-resolver
is needed here as it could be done just by using either one or the other.
By "prepending an _
to the prop" you mean in @connect
? Like:
@connect(({ users }) => { _users: users.data })
@resolve('users', ({ _users }) => _users ? _users : callApi('/users'))
export default class ...
from react-resolver.
I'm using Redux as well as Resolver both. I put it in the Redux store on componentDidMount
(at which point I already have the data loaded using Resolver). For subsequent requests I can read from Redux and skip the XHR.
Now, I am not sure if I should be decorating my component with connect first and then resolver, or the other way around (Let me know your opinion).
react-resolver
just resolves property if the component does not have it already
But it checks it by hasOwnProperty
, so even when the data is undefined
in Redux store, the props will still haveOwnProperty, and the check will think the property already exist.
I am not against checking if the prop already exist, but I think it should be done within the factory. If you have a reason not to do so, then at lease we should check prop's availability by checking it to be non-undefined
.
Makes sense?
from react-resolver.
The scenario makes sense to me, but, when using Redux (or any other application-state manager), React Resolver may not fit in well with it.
I believe redial is the goto for this scenario.
Reason being, react-resolver
was never intended to have to worry about the application changing (and re-re-resolving) unless the route/page changed.
I've personally done the "fake prop so I can dynamically change the real prop value" technique @monder has illustrated above, but I don't know that it's bringing clarity to your project vs. doing things the "redux way".
I hope this helps!
from react-resolver.
Published v3.1.0 on npm. I suppose this issue could be closed as well.
from react-resolver.
Excellent! Thanks
from react-resolver.
Related Issues (20)
- React.renderToStaticMarkup -> ReactDOMServer.renderToStaticMarkup HOT 2
- Can I use this without server rendering? HOT 3
- Add ability to cache resolved props HOT 9
- Using HOC breaks HMR
- Minimum universal react API HOT 1
- test
- Support variable? HOT 3
- Unhandled rejections server side HOT 1
- @context steals data from this.context HOT 6
- Documentation links are broken HOT 4
- Using same component on different routes HOT 3
- Using @client and @resolve on the same class causes @resolve to be called twice HOT 1
- Some way of manipulating data before passing it to component HOT 2
- Breakage with React 16: PropTypes no longer exported by React HOT 1
- "[email protected]" has incorrect peer dependency "react@^0.14.6 || ^15.0.0-0" HOT 5
- Need hydrate static method in the Resolver class for server side rendering HOT 2
- Fix compatibility with Babel 6
- Resolve multiple props with one callback HOT 5
- Initial Data from Django using React Resolver 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 react-resolver.