-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add context support #134
Comments
@wied03 Please do! |
I would request that we keep the syntax consistent with params and state: params.foo Also I am not clear on what the type is for, does it have the same purpose as the optional typing of params? If so again I would want to see consistent syntax. |
You are required to give React a proptype for context. My code converts the Ruby type into a proptype. You could just give it an |
@catmando - As to |
It looks like |
context.foo vs. context[:foo] is just syntax sugar right? it can do the same thing under the hood. Interesting that React requires a proptype. So do we want to be consistent and make it optional (and if not provided we will just use Object as you suggest.) So syntax would be consistent with params
|
I realized I don't have the initializer in the above, but again would like to make it all consistent with param for ease of learning. |
What about the caching question? |
I'm leaving that to @ajjahn. I'm just going from the standpoint that there is no reason why we can't make context.foo work the same as context[:foo]. In fact it should be easier if we wanted to work on it to make context.foo slightly faster than context[:foo]. |
@catmando - I agree there, my mind moved on to the internals of PropsWrapper |
right... so we want to redo the PropsWrapper (and validation too) so that it works for props, and context, plus it work for class level props, and special param types (like observables) without adding burden to the base function if you don't use those features... |
And I'm cool with doing a PR for this since I already wrote it in react-opal. I'm mainly curious about the cache question now. |
@wied03 That cache was added to address #124 and #125. @catmando You implemented a fix for the 0.7.x branch (in a different way). When I pulled it into master things had changed, so I brought the spec you wrote along and made it pass. Those issues are only issues because of the @wied03 We've had discussions on the state and props wrappers. I believe they both could use some TLC. Especially the implementation of state and observables. Too many objects know too much about each other. |
@ajjahn - I'm not really as curious about why the cache is there as much as how you know when to clean it out. If you have a re-render of a component, doesn't the cache as is stick around? |
okay so if part of the confusion is being caused by _react_params_conversion, then lets wrap up that discussion. ( #96 ) |
@wied03 The cache for a prop busts if the underlying component's prop has changed. There isn't a need to mark the entire cache as dirty. When the prop is accessed (regardless of renders), the current value of the prop is examined. Really, the argument could be made that this caching is a concern of the object that responds to |
I'm guessing that the complexity of the cache is worth it? Was it really that expensive to do the camel case/native conversions on demand? |
@wied03 I don't believe camel case/native conversion was the primary reason. The problem here is react.rb has some reactive-record feature envy. Reactive record is counting on react components to deserialize it's models that is is passing as props. I'd like to see serialization/deserialization removed. It belongs elsewhere. So as @catmando suggested, it would be helpful to converge on a consensues in #96. |
This issue was moved to ruby-hyperloop/hyper-react#134 |
In react-opal, you can use the React context feature, like this. I can probably do a PR for this.
The text was updated successfully, but these errors were encountered: