Comments (10)
@acc-nicholas There are a few questions about the repro steps:
- When creating the new repo did you use react preset? or an empty project and added
@nx/react
manually? - Standalone or Integrated project?
- Which builder did you use? the React preset has
Vite
,Webpack
, andRSPack
. - What about test runner? Cypress or Playwright?
- Styles I would assume the default which is CSS modules.
- NX Cloud probably skipped it.
- Did you install the storybook package
@nx/storybook
?
In my local test I did this and without installing storybook I could generate a component with props just fine:
The only caveat I found with my tests was that I had to put my components
folder inside the app
folder, and that the props work as I expected, have to be named props, and have to be typed with an interface, inline types will not work:
Have yet to test inside a library... Tested in a library, same behavior.
from nx.
Related discord post: https://discord.com/channels/1143497901675401286/1209588204127256707
from nx.
I went on a little trip in that forum analyzing the @nx/react
code and trying to figure it out, I thought the issue was the props of the arrow function not being named as props
, I even used a TS AST viewer to check the props text name based on the TS utils used to grab the props interface:
https://github.com/nrwl/nx/blob/master/packages/react/src/utils/ast-utils.ts#L689-L706
from nx.
Thanks @luchillo17 . I was having trouble generating stories for my components. Placing them under the app
or lib
folder solved the issue for me. Not sure why it wasn't mentioned elsewhere or why we even have that restriction.
from nx.
@mamertofabian Worry not, I myself lost a good 15 min trying to make the happy path work until I moved the component into the app
directory, this condition should be stated somewhere in the docs.
from nx.
I have some issues as well.
First, true, I couldn't find a doc saying that components must be in a subfolder called lib
.. Just have to find it yourself.
Then, it worked on 2 packages but not the third one. All three have the same structure:
react
package-1
src/lib/*
package-2
src/lib/*
package-3
src/lib/*
I can generate stories with nx g @nx/react:stories --project=1
and nx g @nx/react:stories --project=2
but not working on the third one.
On the third one, I have this error : Cannot read properties of undefined (reading 'text')
Ring a bell ?
from nx.
hey all!
Could someone provide a minimal reproduction? Or some detailed reproduction steps that lead to a state where the issue can be reproduced.
From this thread, I understand that the issue is mainly caused by having components outside of the app
or lib
folders, but I want to understand how you get to that state so I'm sure I'm solving the right problem and I don't miss anything.
from nx.
@leosvelperez Normally in an Nx monorepo it is the recommended practice to put your code either in the apps
folder or the lib
folder, anything outside of those should be config files, idk if that applies to packages-based monorepo though...
I think the issue stems from people doing packages-based monorepo but do not put their packages in a packages
folder, idk what is the recommended folder structure from Nx for packages...
from nx.
@luchillo17 thanks for the info!
I don't think there's any issue with placing your projects inside a particular folder. From what you described in #22053 (comment), it would seem the issue is that the components are not within the app
or lib
folder within the project root. So, the issue seems to be caused by the placement of the components, not the projects. Nx doesn't enforce a particular folder layout to place projects anymore (with the as-provided
format you can place them anywhere).
That said, the provided reproduction steps in the original report are not too clear and don't lead to reproduction. The reported issue mentions that stories are generated but without props, but I see something different: stories are not generated at all if the components are outside the app
or lib
folder (depending on the project type).
This is why I need proper reproduction steps to understand the issue reported here.
from nx.
@leosvelperez You're correct, the issue I had with the location of the file-blocking storybook generation is separate from the props issue, the specific conditions for the props issue are these:
- Either
props
are not named: The TS utilities that search for the component props search explicitly for function arguments namedprops
. - Or inline prop types: That same TS utility seems to ignore the
props
if it has inline types, you need to use a separateinterface
ortype
(actually, I can't remember if I tried atype
for the props...).
from nx.
Related Issues (20)
- Project Crystal: Using a custom plugin causes the jest plugin to crash HOT 2
- nx.bat prints out its entire contents when it's run
- `npx nx@latest init` fails on Windows when installing `nx/gradle` plugin
- Memory issues building multiple Angular apps with NX on bitbucket pipelines
- Yarn installation error on `create-nx-workspace` and Expo setup due to `peer dependencies are incorrectly met` HOT 3
- Cache not invalidated by previous targets (dependsOn)
- @nx/esbuild:esbuild with `"declaration": true` always executes from $PWD HOT 1
- nx/plugin e2e throws ENOENT out of the box
- Project are not affected when files from default namedInput are touched
- Incorrect serve command in README.md when initializing a fresh React (Remix) project
- Cannot prebuild Expo app with brand new nx monorepo because Gradle `expo-modules-core` HOT 3
- "An error occured while creating pruned lockfile" HOT 2
- Nx CLI is very slow when local plugins implement `createNodes` HOT 3
- [React] [Weback] Cannot run tasks after generated app with webpack and move to nx-enhance
- Getting error Cannot use import statement outside a module in storybook.main after upgrade to v19.1.1 HOT 3
- [Error] Migrate no-extra-semi rules into user config, out of nx extendable configs
- React native storybook issue HOT 1
- [NodeJS executor] Compatibility with non-directory build outputs definition
- Windows: descriptions breaks the Generate UI
- Usage of ungh.cc is not documented and potential security issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nx.