React Fundamentals
It makes sense that JSX must always have a parent container when you think about how it compiles down to
React.createElement. How can you have twoReact.createElementcalls side by side?Babel is actually written in JS, so you can interestingly compile your JSX by placing
type="text/babelin your<script />tag.The
classNameprop is named such because the DOM API names it that way too!The
styleprop accepts camel-cased properties because the DOM API works that way too!When you interact with React's events, it actually returns a
SyntheticEventcreated inside React. It's not coming from the actual DOM (but is pretty darn close).React does this for performance reasons (e.g. event delegation).
If you need to access the native event, just type
event.nativeEvent.
A change in the
keyprop tells React that a component needs to be re-mounted.This is useful when you're working with lists where the order and contents can change.
However, it's useful for intentionally re-mounting too. If you need to restart a component based on some changing variable, you can just make that changing variable the
keyof that component.
Last updated