Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active October 31, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryardley/3093d3c440ea6bdcdfcbc058e03ce5ab to your computer and use it in GitHub Desktop.
Save ryardley/3093d3c440ea6bdcdfcbc058e03ce5ab to your computer and use it in GitHub Desktop.
let firstRender = true;
function RenderFunctionComponent() {
let initName;
if(firstRender){
[initName] = useState("Rudi");
firstRender = false;
}
const [firstName, setFirstName] = useState(initName);
const [lastName, setLastName] = useState("Yardley");
return (
<Button onClick={() => setFirstName("Fred")}>Fred</Button>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment