Profile cover photo
Profile photo
Jason McCarrell
Kind and supporting enough to compensate for my brutal honesty.
Kind and supporting enough to compensate for my brutal honesty.

Jason's posts

Post has attachment

Post has attachment
Is it alright to use uncontrolled form inputs for basic forms?
This is a philosophical kinda thing, I'm also looking for a potential better solution that also avoids state OR a justification why it's ok to attach state for each input.

I'm building a basic CMS that submits forms via ajax, but does nothing else.
When the form loads, I set the input values through defaultValue, then when i submit I grab the values through refs.

I have zero state, which feels good, because I have zero interest in what is in the inputs until I submit the form.

Is it alright to ignore the changing state of inputs? Is grabbing the values from refs ok?

EDIT: I'd like to add. I'm considering using this methodology even as my forms get more complex. So perhaps the body has a rich text editor with a live preview. The textarea would now have a state, however I would continue to simply use defaultValue and refs to manage the form submission. Does this sound right?
8 votes
votes visible to Public
this is fine
Actually.. (please comment)

So I recently ranted about bind hell caused by JS this and thought, what if JSX fixed this issue by having 'this' always refer to the current context the function was written in?

It would save 99% of the bind calls in peoples code. Does this exist?

So If I wrote:
myClassMethod: function() {
    foo(function() {

I wouldn't need to bind(this), because this would already refer to myClass.

So a problem I've been discussing with friends and mulling over:

Web Components could be the best way to write front-ends, however IMO ideally all display html and values should be generated by the server so load times are instant (especially on mobile).

How can one write reactive web components, while also serving their initial page generated by the server side?

Somehow have node parse web components and serve them, then have the UI somehow hook those web components after already having rendered the page (with all values in html)?
This is sort of a thought exercise and challenge. I don't think there is a simple solution, but perhaps I'm wrong.

Post has shared content
UI-Algorithm... very cool insights how things works mathematically #javascript   #design  

I just wrote this to satisfy setting autocomplete options for ng tags input and angular module:
  7    $scope.tagOptions = function() {
  8       return {
  9          then: function(fnc) {
 10             return fnc(['green', 'blue', 'red', 'white', 'yellow']);
 11          },
 12       }
 13    };

Is there not an easier way to satisfy a promise requirement?
This is insane. It's a function returning an object with a value of a function with a parameter of a function that must be called with the value I hope to give for the original variable.

Post has attachment
Web Developers: Have you ever been making a web app and thought 'fuck, now I gotta build my restful api' Or worst, you're working on someone elses project and they have a restful API, but it's not ready for you.

Well, I've solved this problem for MongoDB. I present Generic REST server:

It's a hyper simple node server that you can post/get/put/delete to with the url specifying the collection and it will Insert, find, edit, and delete from the collection according to the data you send to it. No fancy setup, no security, just start testing.
For example, In my contract we've been discussing how to store the information and someone else is supposed to handle that server, but I want to make the forms now, so I just use my generic restful api for now, and switch the url later.

Programming: I made a blog article about my Foray into the Client/Server MVC framework Rendr by AirBnB. I believe it may be the future of web application development. It is just a baby right now though.[sort%20of]

I often want to call code after my view has been added to the browser window's DOM and only after. I was considering extending view to have this functionality, but I was wondering why there isn't native support for this? Often I find if I have to hack around something, I may be doing it wrong, so is there a better way to do this?

An example may be to do some fancy js animation on a dom element for some strange reason.
Wait while more posts are being loaded