⚠️ Spoiler alert! If you haven't watched Westworld perhaps you may want to skip this post.
In the first season of Westworld androids are reset and their memories erased every time they "die" or after each "narrative cycle". Androids cannot take their memories with them (nor learn from them) for the next cycle. In a way they're stateless.
On episode 4 Maeve seems to malfunction and has memories from when the scientists fix her wounds and reset her every time. But this only lasts for one cycle and then she forgets again.
One day, after a daydreaming episode she draws her vision (a man in a hazmat suit) on a piece of paper and starts wondering where to keep the drawing. She suspects everything in her room is carefully reset every time.
She decides to hide the piece of paper under a loose floorboard. When she lifts the board she finds a lot of similar drawings that had been stored in there before.
That's basically React.useState.
Imagine a component with a text input. The user enters some data, but this is a pure function! where do we keep this data for the next time the function is run?
Under a floorboard.
const [drawings, setDrawings] = useFloorboard()
Top comments (0)