How to use the inferno-mobx.useStaticRendering function in inferno-mobx

To help you get started, we’ve selected a few inferno-mobx 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 infernojs / inferno / packages / inferno-mobx / __tests__ / observer.spec.jsx View on Github external
render(, container);

    expect(renderCount).toBe(1);
    expect(container.querySelector('div').textContent).toBe('hi');

    data.z = 'hello';
    // no re-rendering on static rendering

    expect(renderCount).toBe(1);

    expect(container.querySelector('div').textContent).toBe('hi');
    expect(renderCount).toBe(1);

    expect(getDNode(data, 'z').observers.length).toBe(0);

    useStaticRendering(false);
  });
github nightwolfz / inferno-starter / server / middleware / context.js View on Github external
import { useStaticRendering } from 'inferno-mobx'
import { toJS } from 'mobx'
import Account from '../models/Account'
import State from '../../src/stores/State'
import context from '../../src/config/context'

useStaticRendering(true)

const stateClone = JSON.stringify(toJS(new State({})))

/**
 * Middleware for creating the context
 * @param ctx
 * @param next
 */
export default async(ctx, next) => {
  // Get our token from headers (server) or cookies (client)
  ctx.token = ctx.headers['token'] || ctx.cookies.get('token')

  // Check if logged in
  ctx.account = await Account.getAccount(ctx.token)

  // Create state for SSR
github infernojs / inferno / packages / inferno-mobx / __tests__ / observer.spec.jsx View on Github external
it('does not views alive when using static rendering', () => {
    useStaticRendering(true);

    let renderCount = 0;
    const data = mobx.observable({
      z: 'hi'
    });

    const TestComponent = observer(function testComponent() {
      renderCount++;
      return <div>{data.z}</div>;
    });

    render(, container);

    expect(renderCount).toBe(1);
    expect(container.querySelector('div').textContent).toBe('hi');
github infernojs / inferno / packages / inferno-server / __tests__ / observer.spec.server.jsx View on Github external
it('does not views alive when using static + string rendering', function() {
    useStaticRendering(true);

    let renderCount = 0;
    const data = mobx.observable({
      z: 'hi'
    });

    const TestComponent = observer(function testComponent() {
      renderCount++;
      return <div>{data.z}</div>;
    });

    const output = renderToStaticMarkup();

    data.z = 'hello';

    expect(output).toBe('<div>hi</div>');
github infernojs / inferno / packages / inferno-server / __tests__ / observer.spec.server.jsx View on Github external
const TestComponent = observer(function testComponent() {
      renderCount++;
      return <div>{data.z}</div>;
    });

    const output = renderToStaticMarkup();

    data.z = 'hello';

    expect(output).toBe('<div>hi</div>');
    expect(renderCount).toBe(1);

    expect(getDNode(data, 'z').observers.length).toBe(0);

    useStaticRendering(false);
  });
});

inferno-mobx

Official Inferno bindings for Mobx

MIT
Latest version published 11 months ago

Package Health Score

75 / 100
Full package analysis