HNHacker News
TopNewBestAskShowJobs

thenewestkid

82 karma · joined October 20, 2016

submissionscomments
thenewestkid··on Stress Testing React Easy State (with exotic state structures and mutations)
React Easy State (https://github.com/solkimicreb/react-easy-state) is a transparent - ES6 Proxy based - state management library for ReactJS. The marketing pitch of the project is this:

> It doesn't matter how you structure or mutate your state stores, any syntactically valid code works.

In this article, I try to prove this with a simple app and increasingly exotic state structures and mutations.

thenewestkid··on Show HN: React Easy State 6 – Practical Proxy Based React State Management
Easy State is a minimalistic transparent Proxy based React stage management library with a stronger focus on practicality than code beauty. V6 added sync render batching for common task sources to improve performance.
thenewestkid··on Show HN: Simple React State Management
Perf benchmark is here: https://github.com/solkimicreb/react-easy-state#performance You can compare it with vanilla React, Redux and MobX. It is between Redux and MobX, but honestly all of them are pretty performant.

Complexity wise it is much simpler than Redux in my opinion, but its like apple to oranges. It is closer to MobX in philosophy and it is simpler, in exchange of narrower platform support.

Ultimately, just give it a try and judge for yourself (: https://github.com/solkimicreb/react-easy-state#installation. It takes away 10 minutes of your life at worst case.

thenewestkid··on Why the Job Search Sucks
It was nice to randomly find your name here (: Good luck with the interviews, I totally agree with your points. Your blog improved a lot since I last checked it! (The NX framework guy)
thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
Author here. As sigden mentioned, ES6 Proxies can not be transpiled. That is one reason why they are not yet commonly used. You can find out more about them here: https://developer.mozilla.org/en/docs/Web/JavaScript/Referen... (They are pretty awesome).
thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
No, I have never used Vuex, but I think Vue is an awesome framework. My main inspiration was monitoring my problematic situations and state management needs during app development in various frameworks.
thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
As you wish (: You convinced me, I edited the gists and removed the antipattern. Please review it if you have a spare minute. Thx!
thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
Sure, I know about MobX. I use ES6 Proxies instead of the getter/setter based transparent reactivity they use. It allows me to have less edge cases in exchange for narrower platform support.

MobX is also moving in the Proxy direction with v4, but I do not agree with some of their architectural decisions (mostly the synchronous execution), so I made a separate library. We can discuss these later if you are interested.

thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
Valid point. You can move that logic to the component and leave the store for pure data manipulation and handling only. I do that for bigger projects, but in this case I wanted to make things short.

The goal of this series is not to teach patterns but to promote a simple and flexible stack that you can use with the patterns that you like. (In your case you can move the view specific logic to the level of the components).

thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
Passed around local state vs global state is indeed an interesting topic. Honestly I think both are nice in good hands.

The library I made supports both of them, but I did not mention local state management for the sake of simplicity. You can find it here: https://github.com/solkimicreb/react-easy-state#easycomp (it will take 1 min to read).

Doesn't it get clumsy to pass state as props to deeply nested comps?

thenewestkid··on The Simplest React Stack – Part 1: Bootstrapping and State Management
It is actually ES5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

In a nutshell: it is used for computed properties, which compute their value on 'get' operations instead of storing them.

thenewestkid··on Show HN: Simple, Balanced State Management for ReactJS with ES6 Proxies (GitHub)
React Easy State is a simple library, which provides balance between local component state and global stores. It uses a modern version of transparent reactivity (similarly to MobX) with ES6 Proxies under the hood. Please check it out and give some feedback if you have can (:
thenewestkid··on Show HN: Easy State: Simple, Balanced State Management for React with ES6 Proxies
Easy State provides a healthy balance of local and global state management in a simple, scalable way. It consists of two functions only with no hidden complexities. Please give it a try if you have 5 minutes to spare (:
thenewestkid··on Show HN: Easy State: simplified state management for React (learn in a minute)
Great, I would be happy to check you library! Just send a link here or pm me on twitter (@solkimicreb1) when you can share it.

PS: your argument about MobX got me thinking. I decided to add a new function to v2, that creates MobX like external stores for handling global app state more elegantly.

thenewestkid··on Show HN: Easy State: simplified state management for React (learn in a minute)
This is my personal opinion.

Structure wise: Having a singleton app store and separate component states together is the best pattern. Hidden details of a component's functionality should go into its own state. App level data (like the current user) should go into the single app state. Also the minimal set of state that defines the other part of the app state (typically state props from user input) should be two-way reflected in the URL or local storage - depending if its a shareable state detail or user preference.

Timing wise: Synchronous view updates (MobX approach) cost too much performance wise. It is often also not in align with the natural expectation of the developer. (Even MobX has actions, which is just async execution with a bit more granularity). React's approach is a bit too lazy for my taste. Updating the state asynchronously leads to confusion and has no benefit in my opinion. Synchronous state update has practically zero performance cost compared to view updates. Updating the state synchronously and the view asynchronously - but always before the next paint - seems to be the best approach for me. You will never extract existing state from your view and from the user's perspective the only important thing is to have it updated before it is rendered.

Data management wise: I think it is super important for a reactivity library to do not save or alter any of your state. It should just save reactions paired with data mutation/access points. Saving data can cause staleness and mutating your data behind your back is just a mess. I was super careful to leave you objects untouched (opposed to array hacks, hidden getters/setters and memoizing your own getters/setters (computed values)).

In the end Easy State is most similar to MobX. It just saves reactions (renders), which it triggers on state/store mutations. The biggest difference is in its timing (async vs sync), minimal syntax and (in my opinion) fewer edge cases. The difference between using the state vs an external store is pretty much a one line change. They are both normal observable objects, they are just in different locations with different names.

Sorry for the long answer. No worries if you don't have time to read it (:

Edit: I also dislike 3rd party injection libraries (like the MobX @inject decorator). Simple ES6 imports should be enough for injecting the single app state and props should be enough to pass down a component's own state. Angular is a prime example of how more complex injection systems can go wrong. This is just my opinion though and it even might change in the future (:

thenewestkid··on Show HN: Easy State: simplified state management for React (learn in a minute)
You are right. It does use ES6 Proxies and they are not polyfillable. IE and React native is not yet supported because of this (it's mentioned in the platform support section).
thenewestkid··on Show HN: Easy State: simplified state management for React (learn in a minute)
I understand why you might feel like this, but don't judge too quickly (; Easy State can do (pretty much) anything MobX does. It just does it in the background without the extra explicit syntax (observable, action, observble modifiers, etc). You can easily use it like MobX (with an external store) if you do something like this: https://github.com/solkimicreb/react-easy-state/tree/master/....

If you are interested in a MobX vs nx-observe (the library behind Easy State) comparison check this (rather old) article: https://nx-framework.com/blog/public/mobx-vs-nx/. Let me know if you think that it lacks some important features.

Thx for the response!

Edit: it would take a rather small modification to make Easy State work like MobX, but I think that it is not the best way. In the future I could add a @store export for making MobX like stores though.

thenewestkid··on Show HN: Easy State: simplified state management for React (learn in a minute)
I actually think that simpler syntax is a big win. See the key features section for the other advantages (no async issues, optimal shouldComponentUpdate).

About the cost: see the performance section for a third party benchmark. I think you might mean hidden complexity by cost. In that case why would this be more magic than React's own state management? Both are just JS code in the end, and I can assure you I did nothing very hackish under the hood.

thenewestkid··on Show HN: Easy State: simplified state management for React (learn in a minute)
Brief summary (from the repo):

Easy State aims to make React's state management simpler without adding new syntax. To achieve this it makes the following modifications.

It replaces React's setState() with plain native JavaScript. It auto binds your component's methods.

thenewestkid··on A Hacker News clone built with NX
Yes, it is a GitHub hosting issue and it works when the project is run locally. I am aware of the GitHub SPA hack, but I decided against it, since it would introduce unwanted complexity. My main goal with the repo is to teach how to use the NX framework.
thenewestkid··on A Hacker News clone built with NX
Its a framework demo, the goal of it is to teach how to use the framework. After reading all the comments, I think I should clarify it in the repo readme (:
thenewestkid··on A Hacker News clone built with NX
Its just a feature demo, but I actually think that list animations between page changes add value. It makes it easy to spot which stories made it to the top when you switch from new to top for example. (Those stories are animated to their place).
thenewestkid··on A Hacker News clone built with NX
Hi!

I am the author of the NX framework and this example. Thx for posting this here (:

The clone is not intended to be HN alternative, it is an introductory project for the framework.

The redirection issues are because of the GitHub hosting. I am aware of the possible SPA hack, but I decided against it as it would introduce unnecessary complexity to the example project. I will change the hosting soon.

The framework works in all browsers supported by ES6 proxies. (Meaning no IE and Safari 10+ only, rest is pretty much supported). The reason is the reliance on unpolyfillable ES6 proxies. It is a next gen framework that will stay in beta for some time and I hope that by the time I release v1 these browsers will have a lot smaller market share.

thenewestkid··on Handling client-side routing and dynamic parameters (NX framework)
NX is a modular client-side framework, with three separate, focused middlewares for path routing, state-query parameter synchronization and in app navigation. Each of these are 100-200 lines long and easy to use.
thenewestkid··on Show HN: A Hacker News demo in NX, with real-time updates and animations
After a second check: that extra 70kb (on top of the 12kb size of NX) is mostly from the FireBase and EventListener APIs that I use for real-time networking.
thenewestkid··on Show HN: A Hacker News demo in NX, with real-time updates and animations
Strange. Is it the GitHub page or NX home page (or the HN demo page)?
thenewestkid··on Show HN: A Hacker News demo in NX, with real-time updates and animations
Hi!

Thanks for the comment, I think it's pretty constructive. The site is bigger because it is a SPA. It loads every static asset on start, compared to the HN approach which loads only the current page. The NX framework itself is 12kb zipped and 10kb minzipped.

I agree, that it is not a typical use case, but it is starting to become a standard thing for new frameworks (like todoMVC). The point is to implement something that others implement too, to give a fair comparison to users (code).

thenewestkid··on Show HN: A Hacker News demo in NX, with real-time updates and animations
A lot of people commented about similarly named projects in the recent past (mainly Nintendo NX). I am considering a rename along with the beta version coming out soon.
thenewestkid··on Show HN: A Hacker News demo in NX, with real-time updates and animations
About the speed: HN provides a real-time API for SPAs like the NX app, but it is an old fashioned serve-ready-HTML page (a speedy one). I found the API they provide somewhat slower than the site itself. I think other HN SPA clones also suffer from this.

About the site: It is working but things are sometimes not working at some places now because of the DNS attack (pages like GitHub and Twitter are also up and down today.)

thenewestkid··on Show HN: A Hacker News demo in NX, with real-time updates and animations
Valid point, I did that for SEO and I don't think it had much success according to the stats. Going to change it now, thanks.

Edit: Changed it to this. 'NX is a small client-side framework built with ES6 and Web Components. It features routing, data-binding and animations among other things.'

Page 1 of 2Next →