jsprops | Prototype level , OOP | Plugin library
kandi X-RAY | jsprops Summary
kandi X-RAY | jsprops Summary
Properties for JavaScript Prototypes. Library provides class based properties that can be bound directly to a prototype, which reduces redundancy of coping the same property among instances. Additionally, we can easily inherit from Properties class, extending it by our own getters/setter logic. Default property's value is inited in a lazy way, first time it's accessed. Repeated name in a declaration is required by the design.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of jsprops
jsprops Key Features
jsprops Examples and Code Snippets
Community Discussions
Trending Discussions on jsprops
QUESTION
I am very new to ReasonML. I am able to successfully create a stateless component with ReasonReact, but I have not figured out how I might add a custom method to the component (e.g. Next.js' static getInitialProps
).
When attempting to define the getInitialProps
method on the component, I receive a The field getInitialProps does not belong to type ReasonReact.componentSpec
error.
How should I add this define this custom method on the React component?
Component ...ANSWER
Answered 2017-Nov-27 at 02:01Answered in Discord, reposting here:
You can't define arbitrary methods on the component like that. See that ...component
? That's spread a record with static fields and updating a few fields like you did, e.g. render
.
Also, you can't directly pass a ReasonReact component into a next method, I believe. It's probably asking for a react component class. See the interop section on how to expose the underlying js class for the js side.
In the meantime you can probably just wrap that component in a thin layer of js component that defines the getInitialProps
So you'd have a reactjs component that has getInitialProps
, that renders a ReasonReact component that exposed the underlying class through interop.
If I'm understanding you right, you'd also write ReasonReact bindings to that js wrapper if you're using that wrapper from Reason. Which makes this process a bit contrived, but you're hitting a pathological case here.
As an side: ideally, the Next.js API would ask for a component class, and a getInitialProps
on the side, a totally agnostic function that's not attached onto the component class. That'd greatly simplify the binding process on the Reason side.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install jsprops
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