Skip to content

Instantly share code, notes, and snippets.

Avatar
🧭
Building @code-hike

Rodrigo Pombo pomber

🧭
Building @code-hike
View GitHub Profile
View suspense.jsx
import React from "react";
import ReactDOM from "react-dom";
import fetchWithCache from "./cache";
function Post({ postId }) {
const post = fetchWithCache(
"https://jsonplaceholder.typicode.com/posts/" + postId
);
return (
<div>
View componentDidMount.jsx
import React from "react";
import ReactDOM from "react-dom";
class Post extends React.Component {
state = {
loading: true,
post: null
};
componentDidMount() {
const { postId } = this.props;
View memo.jsx
function MyComponent(props) {
/* render using props */
}
function areEqual(prevProps, nextProps) {
/*
return true if passing nextProps to render would return
the same result as passing prevProps to render,
otherwise return false
*/
}
View __.babelrc
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
View __.babelrc
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
View __.babelrc
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
View __.babelrc
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
View __.babelrc
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
View __.babelrc
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}