single-spa / single-spa-react

Single-spa lifecycles helper for React applications
https://single-spa.js.org/docs/ecosystem-react.html
MIT License
227 stars 63 forks source link

Set default custom props when mode is standalone #123

Closed devlucaslopes closed 3 years ago

devlucaslopes commented 3 years ago

Hello, im using single-spa-react and this MFE received some props when is called:

export default function Root({
  access_token,
  oam_cookie,
  locale,
  cart_id
}: AppProps) {}

I would like know is possible set this props with default value when project is running in standalone mode. The script to run in standalone mode is: "start": "webpack serve -- --port=9001",

joeldenning commented 3 years ago

I'm open to this being added. The change would need to be made in standalone-single-spa-plugin. See https://github.com/single-spa/standalone-single-spa-webpack-plugin/blob/d6a6742d5699f2f02b0a59003eb749752f3f45cb/lib/standalone-single-spa.js#L248 where the registerApplication occurs in standalone mode. Do you have interest in submitting a PR that allows passing in customProps?

joeldenning commented 3 years ago

Implemented in https://github.com/single-spa/standalone-single-spa-webpack-plugin/pull/16

joeldenning commented 3 years ago

Released in https://github.com/single-spa/standalone-single-spa-webpack-plugin/releases/tag/v2.1.0