infinitered / ignite-bowser

Bowser is now re-integrated into Ignite CLI! Head to https://github.com/infinitered/ignite to check it out.
https://infinite.red/ignite
MIT License
615 stars 140 forks source link

Finish simplifying component definitions; component & screen generator tweaks #363

Closed bryanstearns closed 4 years ago

bryanstearns commented 4 years ago

Standardized component definitions

After internal deliberation at IR, we've concluded that it's best to use function syntax when declaring functional components (including screens; gets us more-useful stacktraces), and not to use React.FunctionComponent as the parent type of component prop interfaces (see #358). So, plain components are simply:

export function Foo(props: FooProps) {
  // ...
}

Components wrapped with mobx-react-lite's observer HOC (including nearly all screens) use this slightly-more-verbose version (which, yes, has the function name twice, but we feel this is a small price to pay for nice stacktraces!):

export const Foo = observer(function Foo(props: FooProps) {
  // ...
})

So, then, this PR...

I started by cherry-picking the commits from #316 which generates screens in a subdirectory; they needed merge updates against current master (thanks to @lasharela for #316, and to @BrandonSM who contributed very similar work in #331). Then:

bryanstearns commented 4 years ago

@jamonholmgren NB: This replaces the --functionComponent and --stateless-function command line options on ignite generate component (with --observer and --no-observer); not sure whether we count that as a breaking change for versioning...

jamonholmgren commented 4 years ago

Waiting for #362 (cc @nirre7) and then we'll release as 6.0.0.

nirre7 commented 4 years ago

@bryanstearns The whole function thing is "my bad". I though that to be able to use hooks one had to use the React.FunctionComponent .. Yepp, I was wrong. Thank god there are people smarter than me :relieved:

@jamonholmgren I'll try to get the #362 tests sorted today.

infinitered-circleci commented 4 years ago

:tada: This PR is included in version 5.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: