Live data from Hacker News

React JS Best Practices

blog.siftscience.com

91–92 of 92 posts

Re: React JS Best Practices

#91
post #63
post #53

Earlier quoted context omitted.

I noticed in your first code example you use a mixture of leading a method with an _ and some without. Ex. navigateToContact vs _hasUnsavedChanges and _saveChanges. I read somewhere that a best practice is to always prefix custom methods with _ to differentiate from React core methods. What're your feelings on that?

Oh this is definitely a personal preference thing, but our convention is this: private instance methods start with an underscore, public instance methods have no underscore. Public ones have no syntactic difference from the core life cycle methods but that's ok to me because they're all easy to remember. Btw we use public instance methods very sparingly, basically as a last resort when all else fails.

Awesome. Thanks again for the write up. I love reading well written Javascript.

Re: React JS Best Practices

#92
post #88
post #87

Earlier quoted context omitted.

BassCSS is very different from Bootstrap or any other CSS framework. It's more like "classed inline styles", so you build your element styling like 'border border-blue blue bg-white p1 m1' (blue border, blue text on white background, 1 unit padding, 1 unit margin) e.g. you mix-and-match different CSS classes to style your elements. So, I was thinking using React + BassCSS, and build the class string in my React compo…

If that's the case, I stand corrected. But the thing is, I still consider Basscss a solution from the "CSS world". React, IMO, takes it to the next level and combines inline styles with JS features (simple example: https://youtu.be/7YwmS0ny-58?t=58m38s - the scalable font can be done in pure CSS but I could imagine more complex use cases). Still, everybody picks the tools that are best suited for the problem and his/…

Yep, Radium looks pretty cool for dynamic styling.
Post reply on HN