Giter Club home page Giter Club logo

nextjs-effector's People

Contributors

7iomka avatar alexandrhoroshih avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nextjs-effector's Issues

useStore doesn't get store updates

I have the very basic use-case that doesn't work.

My _app.js:

import { withEffector } from 'nextjs-effector'
import * as effectorReact from 'effector-react/scope'


function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}

export default withEffector(MyApp, { effectorReact })

And here is my page:

import { createDomain, forward } from 'effector'
import { useStore } from 'effector-react'

const d = createDomain()
const $s = d.createStore(0)
const change = d.createEvent()

$s.watch((v) => {
  // => here I get all changes correctly
  console.log(v)
})

forward({
  from: change.map(v => v),
  to: $s,
})

export default function Home({ test }) {
  // here value is always '0'
  const v = useStore($s)
  const next = () => {
    change(Math.random())
  }
  return (
    <div>
      {v}
      <button onClick={next}>Next value</button>
    </div>
  );
}

Home.getInitialProps = (context) => {
  return {
    // some props here...
  };
};

The same example works fine in common React app.

Error serializing props returned from `getServerSideProps` in Page (404)

export const getServerSideProps = createGSSP({
  pageEvent: resolverGSSP,
  customize({ scope, context }) {
    const { res } = context
    const isIncorrect = scope.getState(searchModel.$isIncorrect) <- anyway and always is boolean

    if (isIncorrect && res) res.statusCode = 404

    return { notFound: isIncorrect }
  },
})

Got this:

Error: Error serializing props returned from getServerSideProps in "/[...resolver]".
Reason: Props must be returned as a plain object from getServerSideProps: { props: { ... } } (received: [object Undefined]).

Used this as example

GIP issue when navigation is triggered from model

DEMO: https://github.com/7iomka/nextjs-effector-issue-with-router-bindings

  1. Go to My profile page (Gip)
  2. Click to Go to home button on bottom of any page
  3. Instead of navigation - nothing happened

I try to make a research and I found line with issue
https://github.com/7iomka/nextjs-effector-issue-with-router-bindings/blob/master/library/fabrics/get-initial-props.ts#L64

When state.clientScope is used as a scope on navigation on client side allSettled stacks and never resolved.
The only question is - why and how to figure out?
From how I know - allSettled stacks in execution when we have an issue with logic of effects execution, for example - infinite loops.
But in this case, I don't know.

Please help me to solve this problem, bro!

Serverside store init

I have store something like:
export const $cookies = appDomain.createStore<CookiesType | null>(null);

In samples its data available only on server side, on client I get null.
But in components with useStore I get actual data.

Is it possible to init store on server side and then use it in samples on client?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.