Git Product home page Git Product logo

usesse's Introduction

usesse's People

Contributors

dependabot[bot] avatar kmoskwiak avatar leonardoalifraco 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

usesse's Issues

does support dependency query ?

<A>
   <B></B>
</A>

A :

const [dataA, error] = useSSE(() => {
    return fetch("https://myapi.example.com").then((res) => res.json());
  }, []);

B:

const [dataB, error] = useSSE(() => {
    return fetch("https://myapi.example.com", {params: dataA.id}).then((res) => res.json());
  }, []);

query need dataA , how handle this condition ?

Race condition

I'm not sure, maybe I'm doing something wrong, but I've used useSSE hook twice in my app, and now data object unpredictably has my requests results in different order and components receive wrong data.

Judging by the code, the requests are simply inserted in the array as they come, and my code renders asynchronously, so the order of request calls is undetermined.

I've found this repo through this article, and there results are kept by keywords. Is there a reason this idea was abandoned? I'd be more than happy to support each request with some data key, it would be almost like using redux.

Support for React 18

Support new React 18 features:

  • lazy loading on server side,
  • new hydration API and concurrent rendering.

Issue with component rendering

Hi, first of all, thank you for the repo!

Secondly, I tried to use the repo with Razzle SSR. The server part works correctly but I have issue on frontend part. The components with useSSE seems to render correctly, but they rerender again while FE init so there is visible blinking (the API call from useSSE is fired again on FE, trying to reach the same data that are already rendered by server). Are you aware of this, is it a known issue?

Thanks a lot

hi, data got [null, null]

hi,

what hasresolveDatadone ?

i have followed your samples, but got [ null, null ]

// server/index.ts

    await resolveData(3000);

    const markup = renderToString(
      <ServerDataContext>
        <App />
      </ServerDataContext>,
    );

    let html = fileContent.replace(/\<!-- injected-data --\>/g, data.toHtml());
    if (data) {
      html.replace('<div id="root" />', `<div id="root">${markup}</div>`);
    }
    res.send(html);
// client/index.ts

  <BroswerDataContext>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </BroswerDataContext>
// App.tsx

  const data = useSSE(() => api.getPopularRepos('chinese').then((res) => res.json()), []);

  console.log(data, 111);

// here i expected to got a array data,but

i got expected data in client side, but got [null, null], 111 in server side

i don't know why, ty

Using with NextJS and React Library Component

So I have configured a NextJS parent application to use useSSE and it works well with components developed inside the NextJS application. However, I have created component based architecture where I publish a separate React Library project on npm and import those components inside my main NextJS application. These react library components are using useSSE to fetch data. But when I import these react components inside my NextJS parent application, it just fetches the promises and does not resolve the data. I have used the example Todos component demonstrated in this repository to validate the flow. When this Todos component was developed within the NextJS app, it was SSR ready and resolved the data correctly. When I moved this component to my React library, and imported the same from the package instead, I am starting to face this issue. Please help and guide

Remove `key` from params.

key param is unnecessary and may lead to problems with data overwriting in global context.

This is how useSSE should be invoked:

useSSE(
    {},
    () => { return new Promise((resolve) => {}); },
    []
  );

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.