Lape

Lape

  • Docs
  • GitHub

›API

Getting Started

  • Getting Started
  • Thinking in Lape

API

  • lape
  • connect
  • useLape
  • useLapeEffect
  • undo / redo
  • ignoreState
  • lapeTrackUseState

Guides

  • Testing
  • Routing

lapeTrackUseState

If you want to use useState in the same project you are using lape, you should call this function in the index file.

import { lapeTrackUseState } from "lape";

// should be set before first render
lapeTrackUseState()

ReactDOM.render(<App/>, document.body)

Else lape would not know that new state need to be tracked, for example:

import { useState, connect } from "lape";

const Component = () => {
  const [loading, setLoadging] = useState(false);
  const state = useLape({
    count: 1,
  });

  const onClick = () => (state.count += 1);
  
  // if something changes loading to true, state.count would be displayed, but lape would not know that this has happened.
  if (loading) {
    return <Loader />;
  }

  return <div onClick={onClick}>{state.count}</div>;
};

export default connect(Component);
← ignoreStateTesting →
Lape
Docs
Getting StartedAPI ReferenceGuides
Other Projects
Ugnis
More
GitHubStar
Copyright © 2021 Ugnis. All Rights Reserved.