Skip to content

Instantly share code, notes, and snippets.

@pinealan
Created April 1, 2020 02:36
Show Gist options
  • Save pinealan/eea65c9938e771628bde04ada5b0679f to your computer and use it in GitHub Desktop.
Save pinealan/eea65c9938e771628bde04ada5b0679f to your computer and use it in GitHub Desktop.
Brain dump on React concepts of element, component, instance

React: Element, Component, Instance

Element.

<Text>Hello, gini</Text>

Element with clothes off.

{
  type: Text,
  props: {
    children: 'Hello, gini'
  }
}

Component.

() => <Text>Hello, gini</Text>

Component. named so it's reusable.

const Hello = () => <Text>Hello, gini</Text>

Component, but classy. Have more control over it's instance's lifecycles.

class Hello extends Component {
	render() {
		return <Text>Hello, gini</Text>
  }
}

Instances never show up in code. They only exist in runtime. Their runtime behaviour is determined by the use of this in class components, or hooks in function components.

Distilled from this react blog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment