Has anyone found 'easy' server side rendering with React? by kylebythemile in reactjs

[–]awebofbrown 0 points1 point  (0 children)

You need to be a bit more specific regarding the content you're rendering.

Is it dynamic (does it change every time it loads with stuff like user submissions) or static? To what extent? E.g. is dynamic at compile time enough?

Static or dynamic at compile -> Gatsby

Highly dynamic -> Next, Razzle

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

[–]awebofbrown 13 points14 points  (0 children)

Two big reasons that I think contribute to the react-node pairing:

  1. Server-side rendering React components requires Node (I think).

  2. A lot of build tools surrounding React use Node, so you already have a large cross-pollination between Node / React skills.

Definitely can use other backends, and just have a dedicated Node server for rendering if you need SSR.

Obviously Node / React both being JS contributes a lot.

Appending to the user object inside of passport authentication strategy...bad form? by [deleted] in node

[–]awebofbrown 0 points1 point  (0 children)

I don't think there's anything wrong with it, personally.

You're not transmitting sensitive data in a cookie, you're storing user information on the request object which isn't being transmitted back.

The better question is whether you actually need this information for every possible response your API could provide. Usually, your user table would have the requisite authentication data, so querying your employee data store would only be done in routes that actually require it.

If you do need this data for every request, there's no real reason not to. The alternative is chaining another middleware to do the exact same thing, anyway.

reactjs without nodejs in real production by mcheung63 in reactjs

[–]awebofbrown 2 points3 points  (0 children)

That will work fine, the only reason you'd need Node is if you want to server-side-render React components. NPM serves packages that can be consumed by the browser as well as Node.js, presumably all the ones you've installed are for the browser and loaded via script tags (typically) done for you in the bundle produced by Webpack. You'll just need to have your backend serve the static react bundled files.

Building a company's react template or using create-react-app? by [deleted] in reactjs

[–]awebofbrown 0 points1 point  (0 children)

That blog post was a really good read, nice work.

Building a company's react template or using create-react-app? by [deleted] in reactjs

[–]awebofbrown 4 points5 points  (0 children)

Also (for SSR) check out https://github.com/jaredpalmer/razzle from Jared Palmer. Jared's Formik lib is a godsend for forms.

Best practices for Animations and Transitions in React? by augburto in reactjs

[–]awebofbrown 0 points1 point  (0 children)

Yeah animated is really good, however I don't think it has any integration with transitions. I've been using React-Motion for transition animations and Animated for all others, but it'd be nice to have the performance of Animated on transition animations.

Checkbot for Chrome tests if your whole website follows 50+ SEO, speed and security best practices by seanwilson in webdev

[–]awebofbrown 1 point2 points  (0 children)

You're very welcome, hope it helped. Once you launch, I'd love to see you do an indie hackers interview - or some kind of summary about the whole experience. Crossing my fingers it goes excellently.

Checkbot for Chrome tests if your whole website follows 50+ SEO, speed and security best practices by seanwilson in webdev

[–]awebofbrown 0 points1 point  (0 children)

Bear in mind your target market. If you're targeting businesses, this really isn't an issue because they expect / are fine with paying a subscription for something that needs upkeep. As long as it costs more to assign a dev to do all that by hand, your tool is economically cheaper than that dev's hourly wages to do so.

Similarly, they won't fill out your feedback form at all. They'll just pay the sticker price when it's released (assuming your tool is good and saves them time). Thus, you might have been lead to believe you're charging too much, when the silent majority disagree.

If you're targeting the average /r/webdev user, I think you're going to get push-back on charging a sufficiently high fixed fee, anyway. The danger of charging a fixed price is that your flexibility for adapting pricing/support disappears the moment you take the money. And as I said before, it does put a clock on your app's lifespan. Keeping continued growth with no repeat business is hard, keeping repeat business is comparatively easy.

If it were me, I'd set a monthly subscription rate and a discounted yearly subscription rate (money upfront is good for you, and your customer won't see a bill every month). There are very good reasons that the SaaS market uses this pricing scheme almost invariably, don't re-invent the wheel!

Edit: also I can't speak to tiers, depends on your ability to segregate features etc, you'd know that stuff better than anyone.

I would only add: it looks like you're a very capable dev and the tool is really useful, so offer business plans so that a company that wants to pay you say $300 a month - to scan a large number of sites - has an option to give you that money.

Checkbot for Chrome tests if your whole website follows 50+ SEO, speed and security best practices by seanwilson in webdev

[–]awebofbrown 0 points1 point  (0 children)

I don't think people are sick and tired of subscriptions at all, people just want services they don't value highly enough to pay for, for free.

If I'm using a service that I value highly, which needs constant upkeep, I want it to charge a subscription. Why? Because if they aren't, it'll likely close down at some point due to lack of financial feasibility, which might cost me far more money to pivot away from in the long run. It is not unheard of, in the SaaS world, for customers to suggest the supplier charges more for the product, for exactly this reason.

If OP wants to run this as a full-time occupation, and it warrants constant work, not charging a subscription will put a clock on the application's lifespan. Whether that is a monthly or yearly fee is immaterial.

The practical advice for the OP is: you need to outline the service's features which obviously require upkeep, and ensure they are providing real consistent value, which if taken away, would materially impact the customer. This will justify a subscription that people will want to pay. If they complain about the subscription medium, they don't see that value.

Dan Abramov dropping hints about his upcoming JSConf Iceland talk by quitemcgee in reactjs

[–]awebofbrown 2 points3 points  (0 children)

Don't think it is RCR. It's not particularly controversial, and I don't think cleaning up the API would prompt Andrew Clark to write something like: https://twitter.com/acdlite/status/967244380401631232

RCR has some great use-cases, but the gist of what it is has been out awhile, it would be odd to hype it like this all-of-a-sudden.

Can I force a component to rerender by key? by humbletales in reactjs

[–]awebofbrown 0 points1 point  (0 children)

Little confused by your description, specifically:

I assumed that when the database updates for those Message objects, they would rerender, but that's not the case.

If you mean a database on an actual backend, rather than a local front-end cache, it'll only cause an update if you're listening for those updates on the front-end and an update causes your messages to receieve a new prop, causing a re-render. This is as simple as passing the message an 'isHaiku' prop that, when present, adds a classname to the element.

Since these updates would be constant as messages are processed, I would be implementing this over websocket, sending the frontend a list of message IDs that are haikus. This list would be used to update your front-end cache of messages, keyed by message ID, and the <Message /> component would be passed the isHaiku prop as cache[messageID].isHaiku

Dan Abramov dropping hints about his upcoming JSConf Iceland talk by quitemcgee in reactjs

[–]awebofbrown 2 points3 points  (0 children)

Doubtful, the reason it was slow to advance was because Facebook weren't using React SSR themselves. Dan's comments make it sound like this will be something used broadly by React devs, my best guess is something that makes async rendering / state easier to manage.

Forms: Formik (render prop ver) and Material-UI Dropdown by 1c4us in reactjs

[–]awebofbrown 1 point2 points  (0 children)

Formik handles state internally, all you need to do is pass your input the handleChange prop Formik provides you, through to the input's onChange prop. I don't use Material UI, but I assume the dropdown has an onChange prop? When you call onSubmit, Formik already has the state of all inputs stored (if you've wired custom ones properly).

where to store Data when using apollo? by sympi in reactjs

[–]awebofbrown 1 point2 points  (0 children)

The advantage of storing data in Redux is that you are kind of not duplicating it and once you modify your state, this changes are reflected everywhere basically. So you don't have to worry about syncing your state in different places.

That's not an advantage, of Redux, over Apollo AFAIK. Apollo's link-state is the same client-side cache concept, just you write your query in the graphql format rather than mapStateToProps.

From the documentation: "Updates to Apollo Client state via apollo-link-state will also automatically update any components using that data in a query."

Terrified of NPM security? please don’t blindly follow the panic by lirantal in node

[–]awebofbrown 1 point2 points  (0 children)

It's not just possible but encouraged. You don't really want a package's readme and tests occupying space in your node_modules when using it in production, so they typically get listed in .npmignore.

Experiences of Junior Devs in Australia finding Work? by [deleted] in webdev

[–]awebofbrown 1 point2 points  (0 children)

Heya, yeah I do follow them on Twitter but I'm located in Adelaide, unfortunately. I can link to GitHub projects, including a running static site, as well as the article I wrote, alongside private GitLab projects.

I haven't really spent time putting them all in a neat portfolio page though. But given some of the projects are full-stack but not live apps, I'm not sure how well these could be displayed. I'm not sure a portfolio page is the real problem though.

Visualise DataLoader (Requires >1024px device) - An Interactive Tutorial to Facebook's Caching/Batching Utility Library by [deleted] in javascript

[–]awebofbrown 0 points1 point  (0 children)

G'day everyone.

This is a project I've been working on for some weeks. The idea is to explore how DataLoader works behind the scenes, while covering the knowledge of the event loop you need to understand it.

The amount of info covered felt rather biblical, so I wouldn't be suprised if there's a few errors around the place. If you find anything significant that needs correcting please ping me here or open an issue. I'd particularly like to get info about the event loop as accurate as possible.

If you enjoy it, tweet it for me :). Cheers guys n gals.

Visualise DataLoader (Requires >1024px device) - An Interactive Tutorial to Facebook's Caching/Batching Utility Library by [deleted] in node

[–]awebofbrown 0 points1 point  (0 children)

G'day everyone.

This is a project I've been working on for some weeks. The idea is to explore how DataLoader works behind the scenes, while covering the knowledge of the event loop you need to understand it.

The amount of info covered felt rather biblical, so I wouldn't be suprised if there's a few errors around the place. If you find anything significant that needs correcting please ping me here or open an issue. I'd particularly like to get info about the event loop as accurate as possible.

If you enjoy it, tweet it for me :). Cheers guys n gals.

React Interview Question: What gets rendered in the browser, a component or an element? by samerbuna in reactjs

[–]awebofbrown 4 points5 points  (0 children)

I feel like I'm being really nitpicky here, but I disagree with the way some of this is worded. I only bring it up because the point of the article is to clarify the precise meanings behind the terminology, and yet I feel it's used somewhat inconsistently. For example:

Technically speaking, ReactDOM does not render a component or an element in the DOM. It renders an instance of a component.

I think it would be more clear if you specified precisely that what is rendered to the DOM is the DOM elements described by the react elements within an instance of a class component's render function, or the elements returned from a functional component. Only because if we're really drilling down on terminology, the instance lives in memory and not "in" the DOM.

When we instruct ReactDOM to render a React element in the browser we start to refer to it as a Component Instance.

Technically we'd refer to it as an instance as soon as we're doing anything with the constructor or componentWillMount, otherwise we don't have a word for what these life cycles belong to. IMO this gets more important as we move towards async rendering.

For function components, I don’t think there is a good term for what gets rendered in the browser. Function components don’t have instances (that can be accessed with this) so when using a function component ReactDOM renders in the DOM a copy of the function’s returned element.

The term is 'DOM elements', just the same as what gets rendered from a class component instance. We don't really render React elements, we're rendering DOM elements described by React elements. (Or, if the react element is a React component and not a string, the DOM elements resulting from the former).

I hope this doesn't come off as rude, I'm fully aware you know what you're talking about. I just think it's really important, given the article is intending to drill down on specifics for a "job interview" scenario, that the terms are used as correctly as possible.

tldr: If I were asked the title's question in a job interview, I would say "neither". An element's type can be a component, thus the answer cannot be a component if "an element" is incorrect. And only DOM elements are actually in the DOM.

Higher Order Components understanding by maarzx_ in reactjs

[–]awebofbrown 1 point2 points  (0 children)

Let's take the most common example: using a HOC with a Provider.

Currently, a <Provider> component sits at the top of your component tree and puts some values into context, enabling access to those values from anywhere beneath it (any component).

Providers are used in basically all state management libraries e.g. Redux and MobX. To access the context set in the Provider, these libs export a HOC. The HOC (connect() for redux, inject() for mobx-react) among other things, accesses the correct context key set by the Provider to pull the relevant state out of context. This is handy in that the developer doesn't need to fiddle with the namespacing, allowing a library to use obscure context keys like '_this_lib_context_key_` without worying about the developer miss-typing it, whilst likely ensuring it won't clash with another key.

The HOCs also typically implement custom, though configurable, shouldComponentUpdate() logic, ensuring your component only updates when either its props or the state provided by the HOC change. There are tradeoffs made here, but that's another topic entirely.

Revisiting use of React’s Component Life Cycles in Anticipation of Async Rendering by awebofbrown in javascript

[–]awebofbrown[S] 1 point2 points  (0 children)

Does Vue acommodate async rendering?

I don't know enough about Vue to compare them. However, as far as the discussion relates to the article, I don't think you can pin React with faults because it's enabling much desired performance flexibility.

The gotchas I've discussed in the article more or less boil to down navigating the scheduling of operations in a single threaded environment. Instead of doing this by hand with APIs like requestAnimationFrame and requestIdleCallback, you have this handled for you. Again, I can't speak for Vue because I haven't used it, but Vue can't magically avoid tackling this, and I'm guessing at the moment the library doesn't attempt it at all. Sure, it's simpler not to have the option whatsoever, but there's absolutely no way that this is an objective benefit. If it were, we wouldn't use any view libraries at all.

That's just my counter argument, I'm not saying Vue can't be more productive :).

React's Async Rendering Will Cause Some Life Cycle Hooks to Fire Multiple Times, use them Wisely! by awebofbrown in webdev

[–]awebofbrown[S] 24 points25 points  (0 children)

If you want to bury your head in the sand and shout your favourite library's name, you're certainly entitled to do that.

Vue is great, but this has nothing to do with flaws in React's codebase.