Closed cryptic-mystic closed 8 years ago
Could something like this be used to restore an objects type information?
@TheCrow1213 are you planning to reuse the instance of GitHubLoginRequest
elsewhere? If not, can;t you instantiate GitHubLoginRequest
inside your Login
view?
@samsel yeah since I posted this question I've stuck to props that are easily (de)serializable :)
:+1:
Hey there! To preface, I'm new to server side js, and to isomorphic js, and to object oriented JS in general. So I'm not sure if what I'm doing is the 'right' way to do things, but it feels OO to me.
So I'm trying to render a simple anchor tag that points to GitHub's OAuth url. In an attempt to be OO I created this class to represent it:
This object is initialized server-side with a client id, and then passed to my react component:
Notice I'm doing
instanceof
validation to make sure the right object is getting passed in props. Now this works totally fine server side, however on the client side (since react-engine serializes to JSON and then deserializes)LoginRequest
becomes a simple object is no longer an instance ofGitHubLoginRequest
.Am I overcomplicating things? And if I am, it still seems like the current implementation makes it impossible to pass a complex type to a component and still work server side (since in my example, I no longer have access to
getAuthUrl
. I'd like to hear peoples thoughts!