Giter VIP home page Giter VIP logo

issr's Introduction

issr's People

Contributors

alexsergey avatar proutorov 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  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  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  avatar  avatar  avatar

issr's Issues

Add a recoil example

As the title suggests. Recoil is getting some traction lately ; it would be great to get a usage example for it!

Setter function from useSsrState not working as expected

From React API docs:

[When setting a state using hooks] if the new state is computed using the previous state, you can pass a function to setState. The function will receive the previous value, and return an updated value

That means, if we had a count state, for example, and we wanted to increase its value by 1, we would have to necessarily know the current state, so in this case the solution is to pass a function to setCountwhich gets the current value and return the next one:

setCount(currentCount => currentCount + 1)

This works totally fine when using the useState hook from React. Unfortunately useSsrState from iSSR does not work as expected. After the first render if we try to update the state, it only changes once. In this case, being 0 the initial value of count and after using setCount(currentCount => currentCount + 1) once, count's value now becomes 1. This is expected, but then if we try to set count again, it doesn't work anymore, so the value stays in 1.

Infinite Loop using Typescript

I starting using typescript, but getting infinity loop in useSsrEffect.

webpack.config.js

const path = require('path');
  const NodemonPlugin = require('nodemon-webpack-plugin');

const commonConfig = {
 module: {
   rules: [
     {
       test: /\.(scss|css)$/,
       use: ['css-loader', 'sass-loader'],
     },
     {
       test: /\.(ts|tsx)$/,
       use: 'ts-loader',
       exclude: /node_modules/,
     },
     {
       test: /\.jsx$/,
       exclude: /node_modules/,
       use: [
         {
           loader: 'babel-loader',
           options: {
             presets: ['@babel/preset-react'],
             plugins: ['@issr/babel-plugin'],
           },
         },
       ],
     },
   ],
 },
 resolve: {
   extensions: ['.tsx', '.ts', '.js', '.jsx', '.scss'],
 },
};

module.exports = [
 {
   ...commonConfig,
   target: 'node',
   entry: './src/server.jsx',
   output: {
     path: path.resolve(__dirname, './dist'),
     filename: 'index.js',
   },
   plugins: [
     new NodemonPlugin({
       watch: path.resolve(__dirname, './dist'),
     }),
   ],
 },
 {
   ...commonConfig,
   entry: './src/client.tsx',
   output: {
     path: path.resolve(__dirname, './public'),
     filename: 'index.js',
   },
 },
];

App.tsx

import React, { useEffect } from 'react';
import { useSsrState, useSsrEffect } from '@issr/core';
import './styles/index.scss';

const asyncFn = () =>
  new Promise((resolve) => setTimeout(() => resolve({ data: 'Cocker Spaniel' }), 1000));

export const App = () => {
  const [dog, setDog] = useSsrState('Dog image goes here');
  
  useEffect(() => {
    asyncFn().then((data) => {
      console.log(data);
    });
  }, []);

  useSsrEffect(async () => {
    asyncFn().then((data) => {
      console.log(data);
    });

    console.log('LOOP');
    setDog('LOOP');
  });

  return (
    <div>
      <h1>Random dog</h1>
      <img src={dog} height="150" />            
    </div>
  );
};

Screenshot 2021-02-03 at 14 16 00

Where I can find example with typescript?

Do you have example of combination of ApolloClient, React Router and Loadable?

Sould be we go like this?

        const { html: content} = await serverRender.string(() => (
            <ApolloContext.Provider value={{ ...{}, renderPromises }}>
                <ReduxProvider store={store}>
                    <ApolloProvider client={client}>
                        <CacheProvider value={cache}>
                            <StaticRouter location={req.url} context={context}>
                                <GA4Provider>
                                    <MainRoute />
                                </GA4Provider>
                            </StaticRouter>
                        </CacheProvider>
                    </ApolloProvider>
                </ReduxProvider>
                ,
            </ApolloContext.Provider>
        ), {
            outsideEffects: async () => {
                if (renderPromises.hasPromises()) {
                    await renderPromises.consumeAndAwaitPromises();
                  }
            }
        });

TypeError: o is not a function

Hello,

I am trying to use useSsrState in react ssr that is setup in Azure function with Javascript. Since Azure funciton with Javascript doesn't support any module javascript like import issrPkg from '@issr/core'; I have to use .mjs for each file.

After I create a page like these:
import issrPkg from '@issr/core';
const { useSsrState, useSsrEffect } = issrPkg;
const BackupRestoreChecklistDate = (content) => {
const [backupRestoreChecklistDateDisplay, setbackupRestoreChecklistDateDisplay] = useSsrState("test");
return (
createElement("div", {key: generateReactKeys()}, "dasfgdfgdfg")
)
}
export default BackupRestoreChecklistDate;

it gave me the error of TypeError: Cannot read property 'length' of null,TypeError: o is not a function

The version is "@issr/core": "^1.1.0",

Is there any fix for this setup?
Thanks

Documentation outdated and Usage Examples not Working

It looks like the update from 1.2.0 to 2.0.0 has a major change in usage. Before 2.0 the id was autogenerated. Now its required (although not by typescript definition but the it raises an error) and no further context given.

Is version 2.0.0 ready to be used or still work in progress?

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.