How to use @grafoo/bindings - 3 common examples

To help you get started, we’ve selected a few @grafoo/bindings examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grafoojs / grafoo / packages / preact / src / consumer.ts View on Github external
constructor(props: GrafooPreactConsumerProps, context: Context) {
    super(props, context);

    let bindings = createBindings(context.client, props, () => {
      this.setState(bindings.getState());
    });

    this.state = bindings.getState();

    this.componentDidMount = () => {
      if (props.skip || !props.query || this.state.loaded) return;

      this.state.load();
    };

    this.componentWillReceiveProps = next => {
      if ((!this.state.loaded && !next.skip) || props.variables !== next.variables)
        this.state.load(next.variables);
    };
github grafoojs / grafoo / packages / react / src / index.ts View on Github external
constructor(props) {
    super(props);

    let bindings = createBindings(props.client, props, () => {
      this.setState(bindings.getState());
    });

    this.state = bindings.getState();

    this.componentDidMount = () => {
      if (props.skip || !props.query || this.state.loaded) return;

      bindings.load();
    };

    this.componentWillReceiveProps = next => {
      if ((!this.state.loaded && !next.skip) || props.variables !== next.variables) {
        bindings.load(next.variables);
      }
    };
github grafoojs / grafoo / packages / react / src / hooks.ts View on Github external
export default function useGrafoo(config: GrafooConsumerProps) {
  config = config || {};
  let { skip, query, variables } = config;
  let client = useContext(ctx);
  let { current: bindings } = useRef(
    createBindings(client, config, () => {
      setState(bindings.getState());
    })
  );
  let [state, setState] = useState(bindings.getState());
  let { loaded } = state;

  useEffect(() => {
    if (skip || !query || loaded) return;

    bindings.load(variables);

    return () => {
      bindings.unbind();
    };
  }, [skip, query, variables, loaded]);

@grafoo/bindings

grafoo client internal helper for building framework bindings

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular @grafoo/bindings functions