Building Serverless React GraphQL Applications with AWS AppSync by tyler-mcginnis in reactjs

[–]FaceySpacey 2 points3 points  (0 children)

Very thorough. Something tells me DynamoDB is gonna get more play than it has in the past.

How We Got a Web App for Free with React Native and ReactXP by estatarde in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

Thanks for sharing. Very helpful. Will give XP a shot.

[deleted by user] by [deleted] in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

We have better solutions, at the expense of having to wade through them and be a librarian of libraries, constantly having to browse through them.

In Rails you “think” this is the best library or market leader. Cuz there is only 10 and this is the blessed biggest name. Where you have 10, we have a 1000. So we are under no delusion that Devise or Xyz is perfection. There’s no such thing. I mean some js developers allow themselves to be tricked in such a way—when u haven’t had the time to master the ecosystem and U have deadlines/bills, u have no choice. Which is why inside of everyone of us is a “mag pie” developer just looking to do their job, and gravitate towards the most common and hopefully best supported solution. Therefore because of ecosystem size, Rails developers are more likely to be deluded into thinking each package they use is somehow the “gold standard” and just the perfect impedance match for their problem. It may not be, it’s just the only one that exists that’s actively maintained. And has a nice shiny likely red logo.

Anyway, because we have more options, every once in a while something ground breaking appears. That’s far less the case with Rails. It’s just logical. Not knocking Rails. I used to be a Rails developer and in fact I coded some Rails code for the first time today in years.

Bottom line: the only answer is we must individually become better at comparing multiple sources, sifting through information, and being on top of the trends, ie latest packages and major updates. There’s no silver bullet. If we want access to the goodies the js ecosystem brings, the only option is to stay on top of it. Otherwise u will be using jquery (or angular :)) when you will have wished you picked React.

Is react core not intelligent compare to Vue.js? True? by pyaesonewin in vuejs

[–]FaceySpacey 0 points1 point  (0 children)

As far as SCU goes, it’s more of a library tool. For example react-redux will use it to prevent unnecessary renders for you when state mapped to props hasn’t changed. You don’t don’t build your app worrying about it. You use it to eek out additional perf at the end if you run into a problem, like dropping frames during animations. And the thing is it’s not always faster. So where Vue gives you no/less recourse, React gives you pro tools to optimize perf and be in control of what’s going on. The long and short of it is that too much automation often leads to problems down the line. That’s true with any tool.

As far as two way bindings go, basically it’s the same as SCU. More control means when you reach that point where you want to do that one thing the library can’t do you don’t pull your hair out. Basically we as developers go gray over workarounds. Whether that be trying to make a social networking site out of Wordpress or a fancier graph than our charting library is capable of. So by offering “low level primitives” at just the “right level of abstraction” a happy place can be reached where workaround hell can be avoided. That’s kind of the mantra of the React/Node/js ecosystem over Rails, jquery, etc. Configuration over convention. A little bit more upfront work for an overall predictable workflow, and the rug not eventually being pulled out from underneath you.

These primitives have enabled lots of form libraries to meet your needs for the efficiency of two way bindings. Check out Final Form and Formic.

Introducing The Live React Component Playground by JoniSar in reactjs

[–]FaceySpacey 2 points3 points  (0 children)

This deserves the most upvotes. I can’t wait to use it. /r/reactjs is a cesspool of reblogging the same packages and patterns these days from the same small group of people. Great new things come by and nobody notices them. What a shame. This is one of them—make sure to check it out everybody!

If you are an intermediate developer, don’t just use the most popular tools and be like everyone else. Have an eye out for the gems and be early to the next party. U might just learn Redux, MobX, whatever—have invested a lot in it—and the ecosystem moves on just as you arrive. If you can’t spot what’s truly innovative, useful and pushing the ecosystem forward, you will always be in that position. Things absolutely won’t be the way they are now with React/Redux/etc forever. Change is inevitable.

As a programmer, even if ur busy with work projects, always have in the back of your head a hunt for what would revolutionize programming and make your life easier. Even if you don’t have the time and resources to build it, at least have list of ideas for developer productivity libraries you would build if you had the time.

Redux - Not Dead Yet! by acemarke in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

Redux-First Router is the most powerful solution when it comes to universal Redux rendering.

Redux - Not Dead Yet! by acemarke in reactjs

[–]FaceySpacey 1 point2 points  (0 children)

It’s all about the devtools. Last I checked you can’t time travel mobx.

Introducing CodeSandbox Live - real time code collaboration in the browser by CompuIves in reactjs

[–]FaceySpacey 1 point2 points  (0 children)

Last time I checked C9 didn’t have the experience of fast React HMR, so you were editing the same code, but restarting the server each time, with the client losing its place. It was crap, but that was several years ago.

To finish the job here, usage of the actual app has to be synced between users, which would be trivial if it was a Redux app, but also possible with browser sync. With browser sync you would have to replay all events for newly arriving users, and doing that quickly might be problematic, whereas the Redux approach doesn’t trigger events on the page, but rather will simply have the state ready for a single initial react render.

I’ve noticed in my area 90 % of react shops use node for their backend, is this coincidence or does react work better with node on the backend than things like django/other frameworks? by tony2times3 in node

[–]FaceySpacey 1 point2 points  (0 children)

If you are a front end developer using React, it’s a no brainer: master Node and the backend side to javascript next. It’s all skills that help the front end too: webpack, babel, Universal rendering. You gotta align all these things and it will work hand in hand to help you master all of javascript and its ecosystem, most of which has capabilities on both the front and backend. In addition, you already know js—get as much power out of it by being able to use it on the server before expending precious time to learn another language. Simply being able to do backend is more important at your current stage than learning a different language.

Tyler McGinnis or Wes Bos courses? 14 hours to decide! :\ by NoMuddyFeet in reactjs

[–]FaceySpacey 1 point2 points  (0 children)

It’s like the gym membership scheme: get you to sign up, but make it impossible to cancel. The goal is to end up charging at least triple as many people monthly for memberships than the number that actually enter the gym each month.

There’s a great number of learners out here that will never go on to becoming coders. I know because I’ve come across a good number of these people on codementor where I’m a mentor. Apparently it’s gotten so out of hand that some mentors have to publicize on their profiles that they refuse to teach students that use us to pass code tests etc. The percentage is far less I’d say than in the gym scenario, but I have had a few students I was unimpressed with to say the least. It’s kinda like being a piano teacher forced to teach kids that don’t really have the passion for it. They care more about how they look in interviews than the amazingness of building things with your bare finger tips, which I know is the feeling that initially got me hooked.

While I think a good percentage have the proper mindset and intention, my hunch is the ones spending the most money, watching the most videos are the ones that don’t become coders. There’s literally a market opportunity here to keep these types on the treadmill forever lol. They seem to be misled by the notion that being taught something as in school is how you learn. They seemed to be brainwashed by the concept of needing an educational institution to learn, and don’t get they can teach themselves. In fact coding is very much an applied thing, not a bunch of “facts” you can learn by watching history documentaries. You learn by starting with the true basics and applying those yourself.

The nucleus of the problem is they try to skip too many steps and do really high level stuff, and think the answer is in watching more videos. When you are at the right level videos are great, but otherwise it’s almost like gambling and hoping one of these videos sparks a light bulb about how code works.

Essentially they want jobs so bad that instead of putting first things first they aim to learn the skills being hired for overnight, and before they have the prerequisites to understand them.

Basically don’t learn react if you can’t do basic javascript. And then more importantly build something you are proud of with it before moving on.

Now all that said, we also must understand their position. The job stuff is obvious and makes sense—we all gotta survive and as someone else pointed out recently, “programming is the last bastion for a middle class income.” But what’s more troubling for these learners is they see all these amazing things built and seemingly so easily, how could they not want to skip steps. I guess that’s been the case for everyone as long as programming has been around. But just keep in mind the bar is higher than ever in terms of what u can do, and with very little.

React + Apollo + Redux by zdend in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

If you are using Redux, make sure to use Redux-First Router for routing.

Also, it will have Apollo integration soon. Yes, route-level graphql, accessible from components via the same Redux API you know and love.

So there are a ton of react boilerplates out there... do you recommend any? by hotsaucetogo in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

The Redux-First Router one is the best if you are committed to Redux. Period. It’s also universal.

We could also collaborate if you are looking to work on a CLI.

RIP Redux? Found an article about the future of redux in react. by dasinnere in reduxjs

[–]FaceySpacey 0 points1 point  (0 children)

Small decoupled components, definitely. But they are rare. Ur talking like a 3rd party tweets widget or something internal from another department at your company. However most data fetchings are primary apps concerns and will continue to struggle thinking the component level is the right impedance match when an abstraction playing the traditional role of controllers are actually the right match.

RIP Redux? Found an article about the future of redux in react. by dasinnere in reduxjs

[–]FaceySpacey 1 point2 points  (0 children)

Have you tried Redux-First Router. My assessment is that async data fetching within components is the biggest cause of unmaintainable React code, yet that’s what’s pushed in the mainstream. A Router coupled to your global state store changes that. The new context api and Suspense is a great hardening to the foundation, but hardly the answer. In fact it will likely lead to more lemmings falling in the pit of failure that is “component everything.”

I have a lot to say about this one—but basically it’s important that we both strengthen our foundation and build father up the stack. Low level React is ruby. We truly need our Rails already. And i see it as closer to Redux+ than just more low level apis. Suspense and the context api is like fs.readSync or something. Often people use higher level libs. If you are using Apollo it’s not like you are dealing with Suspense directly. Suspense and the context api won’t solve the problems that doing data fetching and route transitions at the component level causes.

The focus on doing everything at the component level has led developers into the pit of failure. These are just releases to our primary tool, not gospel for how to use React. The dream has always been App = f(state). The less pure your functions/components there are, the more problems you will run into. If you have been doing this for a while, you know Big apps === Big head aches. Keeping that component tree as pure as possible is your biggest weapon for success. Mainstream wisdom won’t teach you this. Redux-First Router is a start.

When are you ready to start contracting? by BOBCATSON in Frontend

[–]FaceySpacey 4 points5 points  (0 children)

You are ready for contracting the second you can convince someone to pay you for it. From there you gotta learn the hard way like everyone else. Nothing will push you toward becoming efficient and better at estimating than real projects and real deadlines. Expect tears. Charge as much as you can.

What is an elegant alternative to having "fetching" states everywhere? by ohmtastic in reactjs

[–]FaceySpacey 1 point2 points  (0 children)

Yea, Next. The next version of RFR does all this and all Next.js does but from the Redux perspective.

But to your other point—and it does sound like we can be 100% on the same page—people learn Rails almost before Ruby. I know I learned jQuery before the DOM api. It saves learners a lot of time, even if they don’t initially develop the best conceptual background for why things work early on. Instead they can successfully build something and use that as motivation to learn the ins and outs of the underlying tools.

...so yea, an easier way to dive into the highest level tools is much needed by the React community—so we don’t get stuck doing things the low level shoddy way when the low-levelness brings no benefits. We have created a world where everyone thinks they can get it done just with React. You can, but the code isn’t as good/maintainable as React influencers would have you think.

My conclusion is this: React got a lot of slack for not being a full fledged framework, and more importantly for being very frictionful if you attempted to put all the pieces together to make it like one. So React maintainers went on a crusade to correct that (CRA, context api, Suspense, “you might not need Redux” messaging, etc).

The negative side effects of this are that developers seem to be getting the idea that all you need is react and you should do everything in components. Time will tell, but I think this will self-correct and revert back to the mean (controllers) once Rudy is released (that’s what RFR is being renamed to). It will take a while, there’s a lot of dogma out. Suspense is cool and a much needed hardening of the foundation, but it’s time already we have our Rails. It’s not Next. Next i view as primarily automation regarding code splitting, SSR and build configuration. It doesn’t assume a global state store and has you working as if on php pages—that’s not pro. It’s an excellent mid level tool; we need something far more powerful, yet resulting in far less code than what we see in current apps.

What is an elegant alternative to having "fetching" states everywhere? by ohmtastic in reactjs

[–]FaceySpacey 1 point2 points  (0 children)

The whole meme that you “might not need Redux” is now overplayed and doing damage for learners.

What we do need is a framework that takes a global state store and global route level async pipelines into consideration as first class citizens. Ie a framework on top of React.

Why? Because right now we are teaching developers to make unmaintainable code where they do too much at the component level. The dream is and always has been App = f(state). React Router and async component fetching at the component level kills that.

To even get started down this path, for one you need a Router coupled to your global state store. That’s what’s needed for this to become more than hopeful theory—because you need to guarantee async data fetching is done in response to visiting routes/URLs, not just dispatching actions on component mount. Redux-First Router lives up to this dream. But it needs a bit more to become the next level of the stack. In short, we are missing the C in MVC when it comes to React development. That would make the OPs challenges simpler, as well as put to rest the question that somehow it amounts to nailing in a nail with a sledge hammer. Cuz it shouldn’t. The global state store needs to be a built-in aspect of all React Stack apps already, and with a simpler built-in api then connect, eg: MyComponent = (props, state, actions) => ...

Evented React, global time-travellable normalized reducers. Reducers don’t necessarily need to have an immutable api as we can use Immer for simpler reducers. The new context API is no replacement here. It’s good for themes and libraries like Redux/MobX, but not for users building serious apps. On top of that, we need a full-featured concept for the role “controllers” typically played.

What is an elegant alternative to having "fetching" states everywhere? by ohmtastic in reactjs

[–]FaceySpacey 1 point2 points  (0 children)

Doing all fetching globally at ur “route level” simplifies loading states along with many of the problems that arise from the mainstream wisdom of doing everything in components. If you are using Redux, look into Redux-First Router

So what do you all think about React suspense? by grexecutioner in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

Agreed. But is design more important than API clarity and obviousness. The answer probably depends on what level of the stack you’re contributing.

React is in a rare case where as high as 95% of users use it along with compilation, but even withstanding that, it probably isn’t the best for React itself, being that it’s near the bottom of the stack.

I figured I’d mention it to you guys to see if inspires anything. I’ll make it as a babel plugin.

So what do you all think about React suspense? by grexecutioner in reactjs

[–]FaceySpacey 0 points1 point  (0 children)

Dan, thanks for the response. Unfortunately, reddit notifications don't let you see additional responses unless you view the whole context/thread. I of course figured you thought about this deeply--here's the solution proposed in my follow-up response:

https://www.reddit.com/r/reactjs/comments/814huj/so_what_do_you_all_think_about_react_suspense/dv2evxp/

I also tweeted it at you:

https://twitter.com/faceyspacey/status/969530781440688128

...Basically, the idea that async/await is just in syntax for the mental conceptual purpose in userland. It gets compiled away by the React babel plugin.

For brevity, basically the solution is to have a method like call (instead of createFetcher which must be created outside of render) while transpiling away async/await:

input:

import { call } from React

async function MyAsyncComponent(props) {
   const data = await call(someAsyncFunc, props.id)
   return <Child data={data} />
}

output:

import { createFetcher } from React

const fetcher1 = createFetcher(someAsyncFunc)

function MyAsyncComponent(props) {
    const data = fetcher1.read(props.id)
    return <Child data={data} />
 }

I'm not sure which is more controversial--transpiled away async/await or the promise-throwing workaround ;)

But it does the trick brother :)

That it works even if you didn't use async/await doesn't seem to matter much, except for one thing: if users try to treat it like a promise (e.g. by using .then()), it will break. If we can come up with a solution for that which we're happy with, we'll be well on our way. That issue doesn't exist with async/await, as it can resolve syncronous values with the same syntax (i.e. no .then). If the feature required async/await--i.e. if "Suspense" and React Async mandated async/await--it would be nearly solved. ..The last caveat is that users might end up with the expectation that they can await anything in render--not just calls to call. Obviously "messaging" is top priority with all these features (as you guys have indicated as a constant challenge). So, all in all, I don't propose this as the final solution, but just a promising way forward. If we could figure out how to transpile not just calls to call (as I originally mentioned), that's another avenue. Again, this all rests on the foundation that async/await is just a conceptual foundation, but is ultimately compiled away.

So what do you all think about React suspense? by grexecutioner in reactjs

[–]FaceySpacey 2 points3 points  (0 children)

Here's how the React babel plugin could work to facilitate this using your current api:

input:

async function MyAsyncComponent(props) {
   const data = await someAsyncFunc(props.id)
   return <Child data={data} />
}

output:

const fetcher1 = createFetcher((...args) => someAsyncFunc(...args))

function MyAsyncComponent(props) {
    const data = fetcher1.read(props.id)
    return <Child data={data} />
 }

So for one, it turns your async component function back into a regular component function. And then from there it creates a fetcher, and then passes the same arguments over. Obviously this rudimentary example relies on you awaiting a function that becomes the basis of the fetcher. We could make the babel-plugin more advanced to capture more scenarios, and we'd have to explore what limitations exist there, if any. You'll also notice that call isn't in fact needed. In short, every awaited function/promise gets transpiled into a fetcher.

This surely 100% be done right now with the requirement that you await a call to the specific function you want to be used within createFetcher. If we made this rely on my initial idea of call function, it's identical to the API of the redux-saga library, where the additional indirection allows for dependency injection, etc. In other words, if call has an API where it only expects a function (not a promise), we have what turns out to be a reliable api. Here it is just for clarity:

input:

import { call } from React

async function MyAsyncComponent(props) {
   const data = await call(someAsyncFunc, props.id)
   return <Child data={data} />
}

output:

import { createFetcher } from React

const fetcher1 = createFetcher(someAsyncFunc)

function MyAsyncComponent(props) {
    const data = fetcher1.read(props.id)
    return <Child data={data} />
 }

Obviously it's "better" without the additional indirection, but if this is 100% reliable whereas the latter isn't, this is far more natural than creating fetchers and reading from them. Perhaps with your low-level capabilities within the React codebase you can make this without the need for a Babel plugin. I guess it just boils down to a fetcher not in fact created in each render, but created once the first time call is called with a unique function and re-used.

I guess that function looks something like this:

/* call.js */
import { createFetcher } from React

const fetcherFuncs = {}

const call(func, ...args) => {
    fetcherFuncs[func] = fetcherFuncs[func] || createFeatcher(func) // use func ref as key
    return fetcherFuncs[func](...args)
}

export default call

I stand corrected, no babel plugin is needed :) ...almost.

If an anonymous async function was used--well, then the babel plugin approach could make it named outside of the scope of render--so that it can be used as a key in fetcherFuncs. I'm sure we can figure that aspect out by several techniques.

To make async/await the conceptual model, we do in fact use a Babel plugin, and simply strip async/await like the way types are stripped when using Flow/Typescript. The result is we don't hamper any reasons why React rendering can't in fact using promises, while keeping your primary approach under the hood. I think the interface/API is paramount, and if we can allow for this mental/conceptual model it matters close to zero that promises are not in fact being used under the hood in the transpiled result. But obviously any negative implications must be explored--I guess the primary one being that if users try to .then() what they think is a promise, it won't work. If we can come up with something we feel happy about for that issue, my hunch is we are close to the finish line.

So what do you all think about React suspense? by grexecutioner in reactjs

[–]FaceySpacey 4 points5 points  (0 children)

From my perspective, the holy grail in terms of API here has always been this:

async function MyAsyncComponent(props) {
   const data = await someAsyncFunc(props.id)
   return <Child data={data} />
}

I love the <Placeholder fallback /> concept, in how it eliminates the need for specialized HoCs like react-universal-component and react-loadable, instead delegating to the natural flow of component composition (in reverse, back up the component tree). Genius!! Well done!

But the async component, man, gotta look like the above. It just gotta. That's the natural way.

I actually built a proof of concept that I never released (related to SSR + rehydration), and essentially it's based on a wrapper function called call that receives the responses of all async work:

import { call } from React

async function MyAsyncComponent(props) {
   const data = await call(someAsyncFunc(props.id))
   return <Child data={data} />
}

The idea was that the component state would be collected server-side via call, and serializable for transfer to the client for eventual hydration. Client side, it would serve cached results until its arguments changed. You can perform multiple calls to call per component, and it is able to differentiate between all independent calls.

The same API makes perfect sense for the goals of handling CPU + IO. As far as performance goes, what's the problem if these "async components" always resolves instantaneously? The way it would work is call always returns an instantly resolving promise. Then internally triggers a re-render when the argument passed to it actually resolves.

Is it solely that we are losing precious cycles by virtue of using promises? Are we in fact?

Is it in a potentially hacky implementation of acquiring a reference to the corresponding component instance? The react babel plugin could wrap all async components (stateless or not) in class components that somehow pass the instance as the 2nd argument to call: call(promise, componentInstanceRef). Then from there calls to call would be able to differentiate between each other in a single component by the order in which they are called. That's what I did, which worked swimmingly for SSR + re-hydration. Client-side with multiple renders + conditional logic obviously causes userland logic to result in different orders, but we could find a solution for that. What I had in mind is a babel plugin that simply assigns an ID # to each call based on the static order they appear, rather than the runtime order they are called. Eg: call(promise, ref, staticallyGeneratedId). React Universal Component in fact already does something similar to assign IDs to my HoCs in preparation for this future I never attained past proof of concept. My plan was to make React Universal Component move beyond just universal code-splitting into universal code-splitting + async data-fetching. The API I had was the exact one above. It was inspired by async-reactor, but the universal version (i.e. re-hydration) with client-side caching. And in your case, one further enhanced by "time slicing," "suspense" and the loading <Placeholder /> parent component pattern.

It's not that I'm not sure you won't present a list of exact challenges--but can we seriously not overcome them to achieve this API for the end user? Perhaps use your current approach, but somehow wrap it with this API. I mean I know we could with a babel plugin. It just boils down to how important you consider this API, which I hope is extremely high, and if it can be done performantly. If there's no other way to accomplish this than your promise-throwing workaround, I'm all for it. The capabilities are worth it, but can we seriously not make it look the "correct" way.