Skip to content

Instantly share code, notes, and snippets.

View josephsavona's full-sized avatar

Joseph Savona josephsavona

  • React & Relay at Meta
  • Seattle, WA
  • X @en_js
View GitHub Profile
import { useState } from "react";
export default function CounterWithMutationTracking() {
const [state, setState] = useState(0);
let x = [];
let y = x;
y.push(state);
return (
PASS packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js (18.995 s)
● Console
console.group
⚛️ commit (0b0000000000000000000000000000001)
at console.log (packages/react-reconciler/src/DebugTracing.js:51:27)
console.group
⚛️ commit (0b0000000000000000000000000000001)
// Somewhere, the Redux store needs to be wrapped in a mutable source object...
const mutableSource = createMutableSource(
relayEnvironment,
// Because the state is immutable, it can be used as the "version".
() => relayEnvironment.getVersion()
);
// It would probably be shared via the Context API...
const MutableSourceContext = createContext(mutableSource);
@josephsavona
josephsavona / DelayedQueryRenderer.js
Created July 11, 2017 21:18
Defer loading a QueryRenderer until after mount (useful for client only)
class DelayedQueryRenderer extends Component {
constructor(props, context) {
super(props, context);
this.state = {query: null}; // don't fetch anything initially
}
componentDidMount() {
this.setState({query: this.props.query}); // fetch after mount
}
componentWillReceiveProps(nextProps) {
this.setState({query: nextProps.query});
@josephsavona
josephsavona / MyComponent.js
Created February 28, 2015 19:09
React Container Classes
class MyComponent extends React.Component {
render() {
return (
<div className="user-profile">
<img src={this.props.user.thumbnail} />
<h1>{this.props.user.name}</h1>
</div>
);
}
}
### Keybase proof
I hereby claim:
* I am josephsavona on github.
* I am joesavona (https://keybase.io/joesavona) on keybase.
* I have a public key whose fingerprint is 71DA 232F A47B 8A97 6EF6 141D 9A6D 5124 7BE8 A8B3
To claim this, I am signing this object: