import { State, Observe } from '../es'; import Table from './helpers/table';
An example using React components for a table layout and a button to toggle a boolean state
There a number of factors to consider when buying a car.
Use our special formula to help you decide!
<State initialState={{ vehicles: [ { name: "Volvo", price: 29000, reliability: 7 }, { name: "Honda", price: 25000, reliability: 8 }, ], revealChoice: false, }}
{({vehicles}) => ( Object.values(v))]} /> )}
Which should you buy?
{ ({vehicles, revealChoice, setState}) => { const mostReliable = [...vehicles] .sort((a, b) => b.reliability - a.reliability)[0]; const handleClick = e => { e.preventDefault(); setState(s => ({ ...s, revealChoice: !s.revealChoice })); } return (
Reveal Choice
{ revealChoice &&
);
}
}
You should buy the {mostReliable.name} because it is the most reliable
}