Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
loh
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
10 ms
·
61.
▲
by
loh
5y ago
Great question. As it is now, Molecules are designed to be as independent (platform/vendor agnostic) and flexible as possible. For example, when I was trying out all the different cloud services myself, I was able to connect each of th
62.
▲
by
loh
5y ago
You could be right, but at the same time, many people seem to expect this for free. Perhaps they underestimate the amount of work required to implement quality core functionality, or maybe they feel that all core software should be free and
63.
▲
by
loh
5y ago
That is very kind of you to say. I worked hard on it, but I think it can be better. Marketing and succinctly communicating the value of a solution to a problem has never been my strong suit.
64.
▲
by
loh
5y ago
I agree! There is a lot involved in building full-stack apps, especially with all the different tools available, and Molecule.dev barely scratches the surface. I'll soon be adding presets and templates, which should reduce the complexi
65.
▲
by
loh
5y ago
I've never considered all the different combinations, but it is definitely quite a lot of work, and I'm planning on adding more. My goal with this is to help developers and teams of any level, from beginners to experts, quickly ge
66.
▲
by
loh
5y ago
A good example is probably React. I would consider it to be battle-tested, but it's evolved significantly over the years. "Latest and greatest" would refer to e.g. hooks in the particular case of React.
67.
▲
by
loh
5y ago
Thanks! And yeah, I wish I could release this for free but it requires so much time and effort to do it right that I would end up homeless.
68.
▲
by
loh
5y ago
Most of the tools have been around for quite some time (on the web tech timescale, at least), and they've each evolved and improved as they've been battle-tested. For example, React is pretty state-of-the-art as it has changed (im
69.
▲
by
loh
5y ago
This is exactly why I built Molecule.dev. It's brand new, using all the latest and greatest battle-tested tools. I started it because I recognized that it took entirely too long to implement some of the most basic core functionality
70.
▲
by
loh
5y ago
SEEKING WORK | Colorado, USA | Remote, any timezone I have 15 years of experience building full-stack web applications. My original background is in robotics and embedded systems, but I moved to web apps after realizing their potential. It&
71.
▲
by
loh
5y ago
The docs you linked to are for class components (`this.setState`), not function components using hooks (`useState`). From React's "Using the State Hook" docs: > However, unlike this.setState in a class, updating a state va
72.
▲
by
loh
5y ago
You can think of it very similarly to `useState`, where it returns a particular state and a function to update that state. With `useState`: const [ firstState, setFirstState ] = useState('alpha') const [ secondState, set
73.
▲
by
loh
5y ago
For deeply nested data, I would probably use `immutability-helper`. Many deep spread operators can get ugly and confusing pretty quickly, in my experience.
74.
▲
by
loh
5y ago
Yep! It is syntactic sugar. I personally like it though because it results in slightly cleaner, more concise code. It's just easier on my eyes.
75.
▲
by
loh
5y ago
The API response ends up being the source of truth, in this case. If you wanted to prevent the user from updating the internal state while waiting on the API, you could certainly do that with a check for `updateThingRequest.status === '
76.
▲
by
loh
5y ago
In the examples, `extendState` is used because the API returns only the updated props when updating. Your preference for only `setState` is definitely warranted. The source is available for this reason, and it's pretty compact. You can
77.
▲
by
loh
5y ago
That's a good call. I'll change those to better names. Also, you can call `cancel()` (with no arguments) if you don't want an error. You can find the code for the hooks here: https://github.com/Molecule-dev&#x
78.
▲
by
loh
5y ago
You can certainly compose a `useThing` hook (and others) for more encapsulation and functionality specific to said thing. We actually do this elsewhere as necessary, like with the top level `Store` component. For the most part, it depends o
79.
▲
by
loh
5y ago
I understand. If you get a chance, please clone the core API and app ( https://github.com/Molecule-dev ) and play around with it. Maybe you'll change your mind?
80.
▲
by
loh
5y ago
> Separate your view layer from your application state. It is actually separated, not from React though because React will need the state (data) at some point anyway. We'll go into more detail on that in the next post. To touch on i
81.
▲
by
loh
5y ago
> how do people test this You can find the tests for these hooks here: https://github.com/Molecule-dev/molecule-app/tree/6e2456e216... Is that what you're asking about?
82.
▲
by
loh
5y ago
These patterns are used all throughout an email app built and released earlier this year: https://www.tricepmail.app We'll probably open source portions of it as well eventually, but first we're giving it a huge UI ove
83.
▲
by
loh
5y ago
Yeah. It depends on the data structure and how you'll use/update the state. `extendState` exists for when the situation calls for it. I avoid abusing it.
84.
▲
Two custom React hooks
(blog.molecule.dev)
225 points
by
loh
5y ago
|
174 comments
85.
▲
by
loh
5y ago
Oh, thank you! I just updated the Docusaurus config and it's good now.
86.
▲
by
loh
5y ago
For some reason HN keeps changing the domain from blog.molecule.dev to www.molecule.dev. The URL should be: https://blog.molecule.dev/the-only-custom-react-hooks-we-use
87.
▲
by
loh
5y ago
Love the simplicity and minimalism! I'm a big believer in removing the bulk if possible. This does it very elegantly. Also, the demo does a great job of highlighting exactly how it works.
88.
▲
Show HN: Molecule.dev's TypeScript core is now open source
(github.com)
1 points
by
loh
5y ago
|
0 comments
89.
▲
by
loh
5y ago
Maybe we can release the documentation and tutorials separately, and possibly some of it for free. It's much better if you have all of the code though!
90.
▲
by
loh
5y ago
Thousands of hours have gone into building Molecule.dev over the past year, which itself is the culmination of tens of thousands of hours of experience, honing in on the absolute best tools and approaches. It makes no sense to give it all a
More ›