glenjamin/devboard

Let the card hold state

glenjamin opened this issue · 4 comments

Something like this:

defcard(
  "state demo",
  function(card) {
    return <button onClick={() => card.setState(x => x + 1)>{card.state}</button>;
  },
  { state: 123 }
)

Use a single argument function with properties to make future extensions easier

Like in react, setState should accept an object to merge, or a function to apply to the current state.

part 2: If state is an atom, it should be subscribed to and the function re-rendered whenever it changes.

Added this today in 2a3d416

What does the inspect param stands for?

What does the inspect param stands for?

2a3d416#diff-77ebb40903458615ebd2616b4ea29211R57

Thanks. Sounds useful indeed.