reworm icon indicating copy to clipboard operation
reworm copied to clipboard

What's the use of Provider?

Open xialvjun opened this issue 6 years ago • 0 comments

If you use Provider pattern, why no props to support SSR? If you don't support SSR, why use Provider pattern?

Provider pattern is the way to support SSR, so two different http requests in one nodejs backend program will not share their global state.

app.get('/', (req, res) => {
  // in Provider pattern, store is created in handler 
  // rather than in module top level which is in fact global
  res.end(renderToString(<Provider store={createStore()}><App /></Provider>));
});

xialvjun avatar May 22 '19 00:05 xialvjun