This repo contains the code for reproducing two issues with the @stencil/react-output-target
package in an NX workspace.
Issue 1: @stencil/react-output-target
properties are not available when the component calls connectedCallback
.
When using the library react output target, the properties are not available when the component calls connectedCallback
, they are undefined and becomes available when calling componentWillLoad
. To see the issue:
- Clone the repo.
- Run
npm ci
. - Build the stencil core library by running
npx nx run core-react:build
(this will build the stencil core library and the react output target). - Run the
react-demo
app by runningnpx nx run react-demo:serve
. - Open the browser and check the console. You will see that the
first
,middle
andlast
properties areundefined
when the component callsconnectedCallback
but are available when callingcomponentWillLoad
.
Note
You can check the code in the packages/core/src/components/my-component/my-component.tsx
file.
## Issue 2: ✅ Solved in this PR@stencil/react-output-target
generated components.ts using absolute paths.
The @stencil/react-output-target
package generates the components.ts
file with absolute paths. This causes issues when the project is built in a monorepo environment like NX. To see the issue:
1. Clone the repo.
2. Remove
patch-package
from the postinstall
script in the package.json
file (this is to avoid the @stencil/react-output-target
package from being patched with a workaround for the issue).3. Run
npm ci
.3. Build the stencil core library by running
npx nx run core-react:build
(this will build the stencil core library and the react output target).5. Check the generated components.ts
file in the packages/core-react/src
folder.
When using the library react output target with the SSR target, the component internal shadow DOM is rendered twice. To see the issue:
- Clone the repo.
- Run
npm ci
. - Build the stencil core library by running
npx nx run core-react:build
(this will build the stencil core library and the react output(s) target, SSR target included). - Run the
react-ssr-demo
app by runningnpx nx dev nextjs-demo
. - Open the browser, you will see that the
Hello, World! I'm Stencil React SSR
component rendered twice. - Inspect the component to see the internal shadow DOM rendered twice.