# React Component

Published articles for React Component.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Creating Query Components with Apollo

DevFeed: [Creating Query Components with Apollo](<https://devfeed.tech/articles/creating-query-components-with-apollo-27371.md>)

Original publisher: [Read original article](<http://engineering.khanacademy.org/posts/creating-query-components-with-apollo.htm>)

Author: Khan Academy

Published: 2017-06-12T22:00:00Z

Content type: tutorial

Language: en

Sources: [Khan Academy](<https://devfeed.tech/sources/khan-academy.md>)

Topics: [GraphQL](<https://devfeed.tech/topics/graphql.md>), [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [apollo](<https://devfeed.tech/tags/apollo.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [examples](<https://devfeed.tech/tags/examples.md>), [flow](<https://devfeed.tech/tags/flow.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [news](<https://devfeed.tech/tags/news.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [web-frontend](<https://devfeed.tech/tags/web-frontend.md>)

### AI overview

This tutorial explains a Query Components pattern for React applications using Apollo and GraphQL. The pattern separates data definitions from presentational components, allowing the presentational layer to remain independent of Apollo and GraphQL. Examples cover filtering by postal code, loading and error states, empty results, and Flow types.

### Source excerpt

By Brian Genisio Here at Khan Academy, we've been using GraphQL in several projects with great success. GraphQL ... Read more

## RSC for Astro Developers

DevFeed: [RSC for Astro Developers](<https://devfeed.tech/articles/rsc-for-astro-developers-36193.md>)

Original publisher: [Read original article](<https://overreacted.io/rsc-for-astro-developers/>)

Published: 2025-05-06T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dan Abramov](<https://devfeed.tech/sources/dan-abramov.md>)

Topics: [Astro](<https://devfeed.tech/topics/astro.md>), [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [astro](<https://devfeed.tech/tags/astro.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>)

### AI overview

This tutorial compares Astro's server-rendered Astro Components and interactive Client Islands with React Server Components and Client Components. It explains their similar mental models and highlights differences in syntax, file structure, props, templates, and the use of directives to separate server and client code.

### Source excerpt

Islands, but make it fractal.

## JSX Over The Wire

DevFeed: [JSX Over The Wire](<https://devfeed.tech/articles/jsx-over-the-wire-36177.md>)

Original publisher: [Read original article](<https://overreacted.io/jsx-over-the-wire/>)

Published: 2025-04-16T00:00:00Z

Content type: article

Language: en

Sources: [Dan Abramov](<https://devfeed.tech/sources/dan-abramov.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [API](<https://devfeed.tech/topics/api.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [database](<https://devfeed.tech/tags/database.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [ui](<https://devfeed.tech/tags/ui.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

The article explores an inside-out approach in which an API returns React components or JSX rather than only JSON data. It then examines the difference between raw Models stored in databases and personalized, aggregated ViewModels consumed by a UI.

### Source excerpt

Turning your API inside-out.

## Feature-Based React Architecture

DevFeed: [Feature-Based React Architecture](<https://devfeed.tech/articles/feature-based-react-architecture-18956.md>)

Original publisher: [Read original article](<https://www.robinwieruch.de/react-components-database-relations/>)

Author: Robin Wieruch

Published: 2024-11-25T05:50:46Z

Content type: tutorial

Language: en

Sources: [Robin Wieruch](<https://devfeed.tech/sources/robin-wieruch.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [Database](<https://devfeed.tech/topics/database.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [component](<https://devfeed.tech/tags/component.md>), [database](<https://devfeed.tech/tags/database.md>), [database-relations-react-components](<https://devfeed.tech/tags/database-relations-react-components.md>), [feature-based-react-architecture](<https://devfeed.tech/tags/feature-based-react-architecture.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [structure](<https://devfeed.tech/tags/structure.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

This tutorial explains how database relationships can influence React component design in full-stack applications. It recommends composing focused components around individual features and separating data-fetching functions by domain to avoid increasingly complex nested relations.

### Source excerpt

How Database Relations inform React Components and how Component Composition is the solution to the problem ...

## How to Drag and Drop in React

DevFeed: [How to Drag and Drop in React](<https://devfeed.tech/articles/how-to-drag-and-drop-in-react-18958.md>)

Original publisher: [Read original article](<https://www.robinwieruch.de/react-drag-and-drop/>)

Author: Robin Wieruch

Published: 2024-10-10T04:56:46Z

Content type: tutorial

Language: en

Sources: [Robin Wieruch](<https://devfeed.tech/sources/robin-wieruch.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [draggable](<https://devfeed.tech/topics/draggable.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [component](<https://devfeed.tech/tags/component.md>), [container](<https://devfeed.tech/tags/container.md>), [draggable](<https://devfeed.tech/tags/draggable.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [npm](<https://devfeed.tech/tags/npm.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [react-dnd](<https://devfeed.tech/tags/react-dnd.md>), [react-drag-and-drop](<https://devfeed.tech/tags/react-drag-and-drop.md>), [state](<https://devfeed.tech/tags/state.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

### AI overview

A step-by-step React tutorial for building vertical and horizontal drag-and-drop lists with @hello-pangea/dnd. It covers stateful items, reusable components, Droppable and Draggable components, and reordering list state after drag events.

### Source excerpt

A tutorial about using Drag and Drop in React by example for a vertical list (later horizontal list) with @hello-pangea/dnd as DnD library ...

## Announcing New Keycloak UI Component Libraries!

DevFeed: [Announcing New Keycloak UI Component Libraries!](<https://devfeed.tech/articles/announcing-new-keycloak-ui-component-libraries-31657.md>)

Original publisher: [Read original article](<https://www.keycloak.org/2024/09/keycloak-customizable-ui>)

Author: Erik Jan de Wit

Published: 2024-09-04T00:00:00Z

Content type: release

Language: en

Sources: [Keycloak Blog](<https://devfeed.tech/sources/keycloak-blog.md>)

Topics: [Keycloak](<https://devfeed.tech/topics/keycloak.md>), [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [releases](<https://devfeed.tech/topics/releases.md>), [npm packages](<https://devfeed.tech/topics/npm-packages.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [design-system](<https://devfeed.tech/tags/design-system.md>), [development](<https://devfeed.tech/tags/development.md>), [idm](<https://devfeed.tech/tags/idm.md>), [kerberos](<https://devfeed.tech/tags/kerberos.md>), [keycloak](<https://devfeed.tech/tags/keycloak.md>), [ldap](<https://devfeed.tech/tags/ldap.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [npm](<https://devfeed.tech/tags/npm.md>), [openid-connect](<https://devfeed.tech/tags/openid-connect.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [release](<https://devfeed.tech/tags/release.md>), [saml](<https://devfeed.tech/tags/saml.md>), [sso](<https://devfeed.tech/tags/sso.md>)

### AI overview

Keycloak announces new React component libraries built on PatternFly for creating account and admin consoles. The article also introduces the npm create keycloak-theme quickstart tool, which currently supports account consoles and is planned to support admin consoles in release 26.0.0.

### Source excerpt

We're excited to announce the release of two new npm packages designed to supercharge your Keycloak customization efforts. These React component libraries, built on top of PatternFly, provide the essential building blocks for crafting Keycloak account and admin consoles. The tool generates sample code for a custom console using our "Composable UI" technique. Essentially, this means that you can build your console out of exported Keycloak components that we intend to support in future releases. The packages are: @keycloak/keycloak-admin-ui This package provides the building blocks for creating a Keycloak admin console. @keycloak/keycloak-account-ui This package provides the building blocks for creating a Keycloak account console. @keycloak/ui-shared This package provides shared components and utilities for building Keycloak UIs. Accelerate Your Development with Our Quickstart Tool Kickstart your project with our npm create keycloak-theme my-theme command. This streamlined tool generates a project structure, essential dependencies, and configuration, saving you precious time. At the moment, the tool is only available for account consoles, but we are working on adding support for admin consoles. This will be available in the next release (26.0.0). Get Started: Run npm create keycloak-theme@latest my-theme. The keycloak server can be started with npm run start-keycloak Start the development server with npm run dev Customize your theme by editing files in the src directory. The keycloak server will connect to the development server and all the changes will be reflected in the browser. Just open your browser and go to http://localhost:8080/realms/master/account/personalInfo and login with admin/admin. This will open the keycloak account console. You will see that the example code has an extra page and some extra content above each page. Key Benefits: Rapid development: Create stunning UIs in less time. Consistency: Adhere to the PatternFly design system for a cohesive loo

## Catching the blur event on an element and its children

DevFeed: [Catching the blur event on an element and its children](<https://devfeed.tech/articles/catching-the-blur-event-on-an-element-and-its-children-37248.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/catching-the-blur-event-on-an-element-and-its-children/>)

Author: Stanko

Published: 2021-09-19T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [browser](<https://devfeed.tech/tags/browser.md>), [component](<https://devfeed.tech/tags/component.md>), [focus](<https://devfeed.tech/tags/focus.md>), [framework](<https://devfeed.tech/tags/framework.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>)

### AI overview

A tutorial explains how to handle blur events on a parent element with focusable children. It uses requestAnimationFrame to wait for the next focus target, then checks whether document.activeElement remains inside the parent before running blur logic such as closing a menu.

### Source excerpt

Recently I implemented a fly out menu in React, and stumbled on the following problem - I had to catch a blur event on the menu, but it had multiple focusable children. When user is tabbing between these menu items, blur event is triggered every time on the parent, followed by the focus event on the next item. As I wanted to close the menu on blur, this would close it before user was able to get to the next menu item. Solution is fairly simple and it is not React exclusive - it can be used with any other framework or vanilla JavaScript. The flow goes something like this: Listen to a blur event on the parent element (in my case it was the menu). This will catch blur event on all of its children too. In the handler, give browser time to focus the next element (by using requestAnimationFrame). Check if the newly focused element is in our parent element. If it is, do nothing, as focus hasn't exited the parent yet. If it is not, we left the parent element completely and it is safe to do our blur logic (in my case, it was closing the menu). Code looks like this: const handleBlur = (e) => { const currentTarget = e.currentTarget; // Give browser time to focus the next element requestAnimationFrame(() => { // Check if the new focused element is a child of the original container if (!currentTarget.contains(document.activeElement)) { // Do blur logic here! } }); }; React component # I pulled out the logic and created a small React component: const ChildrenBlur = ({ children, onBlur, ...props }) => { const handleBlur = useCallback( (e) => { const currentTarget = e.currentTarget; // Give browser time to focus the next element requestAnimationFrame(() => { // Check if the new focused element is a child of the original container if (!currentTarget.contains(document.activeElement)) { onBlur(); } }); }, [onBlur] ); return ( <div {...props} onBlur={handleBlur}> {children} </div> ); }; and usage is pretty straight forward: <ChildrenBlur onBlur={() => { doSomethingCoolOnBlur() }} > <bu

## How to set a React Component or dom element as a background image

DevFeed: [How to set a React Component or dom element as a background image](<https://devfeed.tech/articles/how-to-set-a-react-component-or-dom-element-as-a-background-image-20016.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2021/08/12/how-to-set-a-react-component-as-a-background-image/>)

Published: 2021-08-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>), [Code](<https://devfeed.tech/topics/code.md>), [Front end](<https://devfeed.tech/topics/frontend.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [container](<https://devfeed.tech/tags/container.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [z-index](<https://devfeed.tech/tags/z-index.md>)

### AI overview

A step-by-step tutorial for displaying a React Component as a background-like layer behind a textarea. It uses a relatively positioned wrapper, an absolutely positioned component, a transparent textarea background, a negative z-index, and disabled pointer events on the component.

### Source excerpt

During my internship at HackerEarth, I faced an interesting problem. This blog is about that and how I solved it. Problem: To set a background image to the textarea element. My initial impression on seeing the design was that it would be easy. I thought it's a image but after exploring the code I came to know that it's not an image that we have to show as background instead, it's a React Component. So now what? To solve this problem we need to think from scratch. Solution: First, we will think about how to do it and then will implement it step by step. 1. Think From Scratch In this example, as you can see the content in the body element overlap the background-image. To solve this problem we just need to overlap the React Component with the textarea. 2. Implementation Create a textarea and React Component which we are going to use. The text area is to the left and to the right is the React Component which we are going to set as a background image in the textarea element. Steps: 1.Create a div which wrap textarea and React Component. Set the div position: relative and React Component position: absolute, top: 0 & left: 0. <div className="editor-container"> // position: relative <textarea className="editor"/> <BackGround /> // position: absolute; top: 0; left: 0; </div> 2.To overlap textarea on React component we need to set React Component z-index: -1. .bg-img { position: absolute; top: 0; left: 0; width: 250px; font-family: monospace; text-align: center; color: rgba(0, 0, 0, 0.29); z-index: -1; } As you can see we have a problem now. React Component is below the textarea and we are not able to see. 3.To solve the problem we need to make the textarea background transparent. But then if you click on the React Component you won't be able to edit the textarea. To solve this set pointer-events: none. .editor { height: 400px; width: 400px; background: rgba(0, 0, 0, 0); // background transparent } .bg-img { position: absolute; top: 0; left: 0; width: 250px; font-family: mono

## How UI Design Changes Can Disrupt Software Abstractions

DevFeed: [How UI Design Changes Can Disrupt Software Abstractions](<https://devfeed.tech/articles/can-you-move-the-button-30px-to-the-left-40661.md>)

Original publisher: [Read original article](<https://radek.io/posts/can-you-move-the-button/>)

Published: 2021-05-04T00:00:00Z

Content type: opinion

Language: en

Sources: [Radek Pazdera](<https://devfeed.tech/sources/radek-pazdera.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [Figma](<https://devfeed.tech/topics/figma.md>), [interface](<https://devfeed.tech/topics/interface.md>), [Requirements](<https://devfeed.tech/topics/requirements.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [component](<https://devfeed.tech/tags/component.md>), [figma](<https://devfeed.tech/tags/figma.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [interface](<https://devfeed.tech/tags/interface.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [requirements](<https://devfeed.tech/tags/requirements.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

A developer describes how changing a button's position in a Figma design forced a major restructuring of a React save dialog. The experience shows that changes in requirements or UI designs can have non-linear effects on implementation.

### Source excerpt

And how long will it take?

## New Account Console

DevFeed: [New Account Console](<https://devfeed.tech/articles/new-account-console-31583.md>)

Original publisher: [Read original article](<https://www.keycloak.org/2020/09/new-account-console.adoc>)

Author: Stan Silvert

Published: 2020-09-04T00:00:00Z

Content type: release

Language: en

Sources: [Keycloak Blog](<https://devfeed.tech/sources/keycloak-blog.md>)

Topics: [Keycloak](<https://devfeed.tech/topics/keycloak.md>), [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [CSS](<https://devfeed.tech/topics/css.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [idm](<https://devfeed.tech/tags/idm.md>), [kerberos](<https://devfeed.tech/tags/kerberos.md>), [keycloak](<https://devfeed.tech/tags/keycloak.md>), [ldap](<https://devfeed.tech/tags/ldap.md>), [openid-connect](<https://devfeed.tech/tags/openid-connect.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [saml](<https://devfeed.tech/tags/saml.md>), [sso](<https://devfeed.tech/tags/sso.md>), [themes](<https://devfeed.tech/tags/themes.md>)

### AI overview

Keycloak announces its new Account Console as the default, replacing the old console for most users. Built with React and PatternFly 4, it supports custom themes, custom pages, and pluggable React components.

### Source excerpt

The Keycloak team is excited that our new Account Console is finally final! The old account console is still available for those who need it, but the new version is the default from now on. This new console is written as a Single Page Application with React and PatternFly 4. In addition to the modern look and feel, we make it really easy for organizations to personalize the console with custom themes and even custom pages that can have unlimited functionality. Screen shots of New Account Management Console Theming PatternFly 4 makes it really easy to theme the new account console using its system of CSS variables. All you have to do is tweak a few variables, add your own logo, and the console is perfectly skinned. body { --pf-global--FontFamily--sans-serif: Comic Sans MS; --pf-global--FontFamily--heading--sans-serif: Comic Sans MS; --pf-global--BackgroundColor--dark-100: #2B9AF3; --pf-global--Color--100: #004080; } Create your own sub-pages You may have noticed the "Keycloak Man" section above. The new console includes one of our most requested features. That is the ability to add and remove sub-pages. So we've made it very easy to develop and plug in your own React component and add it to the Account Console. It's even possible to build new pages with nothing but an editor. No build step is required unless you want to use more advanced tools like JSX and Typescript. Of course, this "Keycloak Man" theme is available online as a Keycloak Quick Start so you can check out all the source. The Home for New Keycloak Features New Account Console is the home for user configuration of new Keycloak features like WebAuthn support. So look for new features to start showing up in the New Account Console instead of the old one.

## Building a Data Table Component in React

DevFeed: [Building a Data Table Component in React](<https://devfeed.tech/articles/building-a-data-table-component-in-react-1325.md>)

Original publisher: [Read original article](<https://shopify.engineering/building-data-table-component-react>)

Author: Amber Armstrong

Published: 2018-10-17T17:30:00Z

Content type: tutorial

Language: en

Sources: [Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering.md>), [Shopify Engineering - Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering-shopify-engineering.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Design system](<https://devfeed.tech/topics/design-system.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [jQuery](<https://devfeed.tech/topics/jquery.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>)

Tags: [design-system](<https://devfeed.tech/tags/design-system.md>), [front-end](<https://devfeed.tech/tags/front-end.md>), [legacy-code](<https://devfeed.tech/tags/legacy-code.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [stateful](<https://devfeed.tech/tags/stateful.md>), [stateless](<https://devfeed.tech/tags/stateless.md>), [web-development](<https://devfeed.tech/tags/web-development.md>)

### AI overview

This article explains how Shopify's Polaris team built a data table component in React. It highlights reusable components, props, stateful and stateless subcomponents, lifecycle methods, DOM behavior, event-listener cleanup, and the differences from a jQuery-based approach.

### Source excerpt

I'm a front-end developer at Shopify, the leading commerce platform for over 600,000 merchants across the globe. I started in web development when the industry used tables for layout (nearly 20 years ago) and have learned my way through different web frameworks and platforms as web technology evolved.

## React Router v4 redirect decorator

DevFeed: [React Router v4 redirect decorator](<https://devfeed.tech/articles/react-router-v4-redirect-decorator-37339.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/react-router-v4-redirect-decorator/>)

Author: Stanko

Published: 2018-01-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React Router](<https://devfeed.tech/topics/react-router.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [component](<https://devfeed.tech/tags/component.md>), [export](<https://devfeed.tech/tags/export.md>), [import](<https://devfeed.tech/tags/import.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [react-router](<https://devfeed.tech/tags/react-router.md>), [return](<https://devfeed.tech/tags/return.md>), [router](<https://devfeed.tech/tags/router.md>), [routing](<https://devfeed.tech/tags/routing.md>)

### AI overview

This tutorial explains how React Router v4 handles redirects through rendered components and presents a higher-order decorator that exposes a redirectTo method. The decorator can either replace the current URL or push a new history entry.

### Source excerpt

React Router switched to component based routing starting with the version 4. Redirects are now done by rendering a Redirect component, like this:Please note that you can use included withRouter decorator but it can cause update blocking and introduce side effects. This is small subset of it. <Redirect to='/redirect-url-here' /> What I usually do is to keep redirectTo property in component's state. To redirect, I set it to the URL I want to redirect to, and render Redirect at the start of the render method: render() { const { redirectTo } = this.state; if (redirectTo) { return <Redirect push to={ redirectTo } />; } return ( <YourComponentHere /> ); } This approach works well, but I got tired of repeating the same code over and over again. So I pulled the functionality to a decorator (higher order component if you prefer). Redirect decorator # I did exactly what I described above, and exposed redirectTo method to a composed component. import React, { Component } from 'react'; import { Redirect } from 'react-router-dom'; const withRedirect = ComposedComponent => class RedirectDecorator extends Component { state = { push: false, redirectUrl: null, } componentDidUpdate(prevProps, prevState) { const { redirectUrl, } = this.state; // If component is rendered on redirect page as well // (i.e. header or footer) it would cause redirect-loop // as "<Redirect />" is being rendered every time. // So we are resetting the state after redirect if (!prevState.redirectUrl && redirectUrl) { this.setState({ push: false, redirectUrl: null, }); } } redirectTo = (redirectUrl, push = false) => { this.setState({ push, redirectUrl, }); } render() { const { push, redirectUrl, } = this.state; if (redirectUrl) { return <Redirect push={ push } to={ redirectUrl } />; } return ( <ComposedComponent { ...this.props } redirectTo={ this.redirectTo } /> ); } }; export default withRedirect; Usage # Import newly added decorator and apply it to your component. It will inject redirectTo to it's props, and

## React ratio

DevFeed: [React ratio](<https://devfeed.tech/articles/react-ratio-37336.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/react-ratio-component/>)

Author: Stanko

Published: 2018-01-23T00:00:00Z

Content type: release

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>)

Tags: [demo](<https://devfeed.tech/tags/demo.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [release](<https://devfeed.tech/tags/release.md>)

### AI overview

The author presents react-ratio, a small React component that creates an element with a specified aspect ratio. The article points readers to a demo and the source code.

### Source excerpt

Short one today. I'm continuing to release small libraries. So let me present react-ratio, another small React component. You probably guessed what it does - creates element with the given aspect ratio. Check the demo or grab the source code

## Key Takeaways from GraphQL Summit 2017

DevFeed: [Key Takeaways from GraphQL Summit 2017](<https://devfeed.tech/articles/key-takeaways-from-graphql-summit-2017-23436.md>)

Original publisher: [Read original article](<https://www.apollographql.com/blog/key-takeaways-from-graphql-summit-2017-b292d6fa121b>)

Author: Xavier Cazalot

Published: 2017-12-07T22:52:00Z

Content type: opinion

Language: en

Sources: [Apollo Blog](<https://devfeed.tech/sources/apollo-blog.md>)

Topics: [GraphQL](<https://devfeed.tech/topics/graphql.md>), [API](<https://devfeed.tech/topics/api.md>), [Microservice](<https://devfeed.tech/topics/microservice.md>), [React Component](<https://devfeed.tech/topics/react-component.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [apollo](<https://devfeed.tech/tags/apollo.md>), [community](<https://devfeed.tech/tags/community.md>), [conference](<https://devfeed.tech/tags/conference.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [guest-post](<https://devfeed.tech/tags/guest-post.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [production](<https://devfeed.tech/tags/production.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [summit](<https://devfeed.tech/tags/summit.md>)

### AI overview

A guest post presents five takeaways from GraphQL Summit 2017, including increased production adoption, schema stitching for combining schemas into a unified API, GraphQL subscriptions, and growing interest in API management for complex architectures.

### Source excerpt

This is a guest post from Xavier Cazalot, engineer and GraphQL trainer at OK GROW! and was originally published at okgrow.com. GraphQL Summit wasn't about advanced GraphQL: this was cutting-edge GraphQL! -- a GraphQL Summit attendee The above quote reflects two awesome aspects of the GraphQL ecosystem: - Compared to last year, there were significantly more people at the conference already using GraphQL, including a large number of people using it in production systems.

## Apollo Tote, Declarative Patterns and a Sneak Peek into Apollo 2.0

DevFeed: [Apollo Tote, Declarative Patterns and a Sneak Peek into Apollo 2.0](<https://devfeed.tech/articles/apollo-tote-declarative-patterns-and-a-sneak-peek-into-apollo-2-0-23224.md>)

Original publisher: [Read original article](<https://www.apollographql.com/blog/apollo-tote-declarative-patterns-and-a-sneak-peek-into-apollo-2-0-f23bd884943e>)

Author: Peter Piekarczyk

Published: 2017-10-10T23:51:00Z

Content type: tutorial

Language: en

Sources: [Apollo Blog](<https://devfeed.tech/sources/apollo-blog.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [Library](<https://devfeed.tech/topics/library.md>), [Expo](<https://devfeed.tech/topics/expo.md>), [Redux](<https://devfeed.tech/topics/redux.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [community](<https://devfeed.tech/tags/community.md>), [guest-post](<https://devfeed.tech/tags/guest-post.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [react-native](<https://devfeed.tech/tags/react-native.md>), [redux](<https://devfeed.tech/tags/redux.md>), [render](<https://devfeed.tech/tags/render.md>)

### AI overview

This guest post introduces Apollo Tote, a declarative React component and helper library for Apollo queries. It explains how to use render props and JSX to handle query data, loading and error states, with examples including authentication and authorization flows.

### Source excerpt

This is a guest post from Peter Piekarczyk, technical co-founder and Apollo / React Native guru at Orchard.ai. Apollo Tote is a declarative React component. Take what you've been doing inside your "smart" containers and apply it with JSX! It's meant to be a simple helper library for your Apollo queries until declarative components are released in Apollo 2. I created this because I don't believe separate components and containers need to be applied everywhere.

## React Image Filter

DevFeed: [React Image Filter](<https://devfeed.tech/articles/react-image-filter-37335.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/react-image-filter-component/>)

Author: Stanko

Published: 2017-09-02T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [SVG](<https://devfeed.tech/topics/svg.md>), [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [github](<https://devfeed.tech/tags/github.md>), [interactive](<https://devfeed.tech/tags/interactive.md>), [npm](<https://devfeed.tech/tags/npm.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [svg](<https://devfeed.tech/tags/svg.md>)

### AI overview

A tutorial describing a React component that applies color filters to images using SVG feColorMatrix transformations. It explains matrix-based filter values, an interactive range-slider demo, and a wrapper technique that preserves image aspect ratio in browsers where CSS SVG filters are unsupported.

### Source excerpt

On the project I'm currently working on, client's logo is displayed in two versions, black on the white background and vice versa. To make their life easier, so they don't have to upload two assets, I suggested SVG. Alas they can't use SVGs (kinda long story), so I just applied CSS filter: invert(1);, but... ...you guessed it - it doesn't work in IE and Edge :( So I started reading about SVG filters and found a way to invert a image. But it got me interested, so I kept going and made a React component for all sorts of color filters. Play with the interactive demo. Documenation available on GitHub and npm. SVG filters include feColorMatrix which is a matrix for color transformation. Changing the matrix value you can achieve all of the CSS filters. It accepts 5x4 matrix. Two examples: // Base matrix (no filter) 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 // Invert colors matrix -1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 I wasn't lazy so I made interactive way of changing values in matrix. Every value has it's own range slider. This way you can see the changes right away. Soon I encountered another problem. As applying SVG filters in CSS also doesn't work in IE and Edge, I used SVG <image /> tag. But SVG wouldn't scale to the image size. Then it hit me, I can solve it by using a simple hack. Component is rendering a wrapper div with SVG inside. So I added a <img /> using the same image and div resizes to fit the image. Here comes the hack - I've hidden the image using visibility: hidden and made SVG absolute and 100% width/height. This way SVG always keeps image aspect ratio. SVGs are awesome :)

## Plx - React parallax component

DevFeed: [Plx - React parallax component](<https://devfeed.tech/articles/plx-react-parallax-component-37330.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/plx-react-parallax-component/>)

Author: Stanko

Published: 2017-07-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [Code](<https://devfeed.tech/topics/code.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>)

### AI overview

This article introduces Plx, an open-source React component for creating parallax effects driven by scroll position. It explains the component's scroll manager, viewport-based animation behavior, and performance optimizations.

### Source excerpt

I'm becoming predictable. Again, I haven't found component I like, so I wrote my own. This time, I've build React component for parallax (on scroll) effects. Check the live demo. It is called Plx, it is open source and available on GitHub and npm. What it does # So far in my career, I've built so many parallax components. Parallax is actually wrong termthe effect whereby the position or direction of an object appears to differ when viewed from different positions, e.g. through the viewfinder and the lens of a camera. here, but it got accepted by development community. Designers love them and users are fascinated by fancy effects. Simply explained as you scroll the page down something is changed relative to the scroll position. For example, as you scroll you can make things explode! Just check the demo. There is a lot of solutions out there, but IMHO they are usually bloated or not performant or complicated to use. And as I'm using React a lot, I decided to collect what I have learned about implementing on scroll effects in React and create standalone component. Most of the code in this component is pulled out from my existing projects and glued together. Performance # Plx is really performant, thanks to a few optimizations. First and the most important one - it is not listening to window scroll event. It is using simple scroll manager, which checks if scroll has changed every 16ms (to get smooth 60fps). When scroll changes it broadcasts custom event. All of the Plx components are listening to this event and share the same scroll manager (it is singleton). Singleton is created with the first component, and destroyed when last one unmounts. Another optimization is that elements are not animated when not in viewport. Actually, they are not animated if they are more than 50px outside of viewport. So component "gets ready" 50px before it enters the viewport. You can force animating element even outside of viewport by setting animateWhenNotInViewport prop to true. Beside

## Animate React component by calling 'setState' in 'componentDidMount'

DevFeed: [Animate React component by calling 'setState' in 'componentDidMount'](<https://devfeed.tech/articles/animate-react-component-by-calling-setstate-in-componentdidmount-37337.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/react-rerender-in-component-did-mount/>)

Author: Stanko

Published: 2017-06-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [React UI animations](<https://devfeed.tech/topics/react-ui-animations.md>), [how to create smooth CSS transitions](<https://devfeed.tech/topics/how-to-create-smooth-css-transitions.md>), [CSS](<https://devfeed.tech/topics/css.md>), [browser](<https://devfeed.tech/topics/browser.md>)

Tags: [animation](<https://devfeed.tech/tags/animation.md>), [browser](<https://devfeed.tech/tags/browser.md>), [code](<https://devfeed.tech/tags/code.md>), [css](<https://devfeed.tech/tags/css.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>)

### AI overview

A tutorial explains why changing a React component's state in componentDidMount may fail to produce a CSS transition. It attributes the behavior to browsers merging changes made within the same animation frame, and discusses using a timeout or animation-frame approach to separate the rendered states, including inconsistent Firefox behavior.

### Source excerpt

On the frontend, we do a lot of animations. Most of the simple animations I create by using CSS transitions. Either I will change class or inline style of the element, and define transitions in CSS file. Easiest way to do this in React is to render initial state, and then when it renders, change the state to apply class or style to animate. The easiest way to do it in React is to change state in componentDidMount. Setting state in componentDidMount is considered to be anti-pattern, as it forces rerender and can lead to property/layout thrashing. But in our case, that is exactly what we want to do. When we do that, we hit the wall - only second state is rendered and there is no transition between two states. It happens because of browsers optimization - browsers are not rerendering stuff that changed in the same animation frame. But they merge changes and render the end result. The problem I just described is not React exclusive, but browser related. Same will happen if we try something like this: const element = document.querySelector('.AnimateMe'); element.style.height = '50px'; element.style.height = '250px'; So let's start with example of the problem. Animate component by changing state in componentDidMount doesn't work # The scenario I described above. Element height depends on this.state.animation property. It is initially set to false and element height should be 50px. In componentDidMount we'll change the value of this.props.animation to true and element height should be 250px. As we added transition, it should animate. But it doesn't as all of this happens really fast, and browser decides to merge changes and render only the end result. This way our element immediately gets height of 250px. import React, { Component } from 'react'; export default class AnimateMe extends Component { constructor(props) { super(props); this.state = { animate: false, }; } componentDidMount() { this.setState({ animate: true }); } render() { return ( <div style={ { background: '#e

## React scroll decorator

DevFeed: [React scroll decorator](<https://devfeed.tech/articles/react-scroll-decorator-37340.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/react-scroll-position-decorator/>)

Author: Stanko

Published: 2017-05-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [React Component](<https://devfeed.tech/topics/react-component.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>)

Tags: [javascript](<https://devfeed.tech/tags/javascript.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [performance](<https://devfeed.tech/tags/performance.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>)

### AI overview

A tutorial presents a React scroll-position decorator that injects scroll position into component props. It uses a timed interval to throttle requestAnimationFrame checks instead of directly handling scroll events, while warning that applying it to many components may cause performance issues.

### Source excerpt

Update, December 2017 # Check this post for updated, more performant version. I love JavaScript decorators. One that I copy to every React project is scroll decorator. It is fairly simple way of injecting scroll position to react components. This way you can handle scroll using react lifecycle. This decorator is not listening to a scroll event, as that is the performance killer (especially when you push it to react lifecycle). Instead, it is using interval to check if scroll position has changed. To keep it performant, I'm using requestAnimationFrame. Interval is only there to throttle animation frame from triggering too often. Please note that it still may cause performance issues if you apply it to a large number of components. Personally, I never had to apply it to a more than three of four per page. So here it is: import React, { Component } from 'react'; const withScroll = ComposedComponent => class ScrollDecorator extends Component { constructor() { super(); // Initial scroll position this.state = { scrollPosition: this.getWindowScrollTop(), }; // Bind handlers this.handleInterval = this.handleInterval.bind(this); this.handleRequestAnimationFrame = this.handleRequestAnimationFrame.bind(this); } componentWillMount() { // 50 times per second, change to your needs const INTERVAL = 20; this.intervalID = setInterval(this.handleInterval, INTERVAL); } componentWillUnmount() { // Remove and reset interval/animationFrame clearInterval(this.intervalID); cancelAnimationFrame(this.requestID); this.requestID = null; this.intervalID = null; } getWindowScrollTop() { // Get scroll position, with IE fallback return window.pageYOffset || document.documentElement.scrollTop; } handleInterval() { // Interval is only used to throttle animation frame cancelAnimationFrame(this.requestID); this.requestID = requestAnimationFrame(this.handleRequestAnimationFrame); } handleRequestAnimationFrame() { const { scrollPosition } = this.state; const newScrollPosition = this.getWindowScrollTop()

## Sektor - draw and animate SVG sectors

DevFeed: [Sektor - draw and animate SVG sectors](<https://devfeed.tech/articles/sektor-draw-and-animate-svg-sectors-37348.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/sektor-draw-and-animate-svg-circle-sectors-2016/>)

Author: Stanko

Published: 2016-06-29T00:00:00Z

Content type: article

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [SVG](<https://devfeed.tech/topics/svg.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Library](<https://devfeed.tech/topics/library.md>), [browser](<https://devfeed.tech/topics/browser.md>), [React UI animations](<https://devfeed.tech/topics/react-ui-animations.md>)

Tags: [animate](<https://devfeed.tech/tags/animate.md>), [browser](<https://devfeed.tech/tags/browser.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [library](<https://devfeed.tech/tags/library.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [svg](<https://devfeed.tech/tags/svg.md>)

### AI overview

This article introduces Sektor, a plain JavaScript library for drawing circular sectors or arcs in SVG. It explains that the sector angle can be changed and animated, and notes browser support including IE10 and modern browsers with SVG and requestAnimationFrame support.

### Source excerpt

For a current project I'm on, we needed both circular timer, and progress bar. Again, I wasn't able to find small library to do that. But I found awesome answer on Stack Overflow, decided SVG is way to go, and wrote Sektor. Sektor is a plain JavaScript library that draws circle sector (or an arc). Once it is drawn, you can change it's angle and animate the change. It works in every browser with SVG and requestAnimationFrane support (IE10+ and modern browsers). Check demo and docs. I may use this for example how much better is to use requestAnimationFrame than setInterval. If you are bored, try it yourself, and you'll see that animating using requestAnimationFrame is way smoother. React component is coming soon as well. Cheers!