Skip to content

Commit f872490

Browse files
authored
Pre-81: Switch to newer rendering pathways for stagedRender and improve type safety of framework (#3996)
* update phasedComponent pattern and switch direct stagedComponent callers to use it * Change files * fix use-slot to use new rendering patterns * Change files * tighten up typing for framework, fixing the resulting errors * Change files * fix break from merge * add prop extraction helper and remove hack from switch * fix package linting error * fix useSlot implementation * fix overflow rendering * ensure old codepaths are consistent in behavior * update framework-base documentation and fix logic bug * fix dead links in markdown files * Change files
1 parent a9ed607 commit f872490

98 files changed

Lines changed: 776 additions & 416 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide assumes you:
66

77
- Have read through the [React Native Docs](https://reactnative.dev/docs/getting-started). In particular:
88
- Understand classes vs function components (we use the latter) and [hooks](https://reactjs.org/docs/hooks-intro.html). Here's a good [video](https://www.youtube.com/watch?v=dpw9EHDh2bM) that explains function components and hooks for traditional OOP developers.
9-
- Understand [Native Modules](https://reactnative.dev/docs/0.74/native-modules-intro).
9+
- Understand [Native Modules](https://reactnative.dev/docs/turbo-native-modules-introduction).
1010
- Have a local fork of FluentUI React Native and have run the test app.
1111

1212
## Understanding the Repository Structure
@@ -44,7 +44,7 @@ Tokens help us achieve simpler customization for complex higher order components
4444

4545
This section covers creating and adding a new component package to FluentUI React Native's monorepo. If you are instead working on an existing component and adding a native module, skip to the next two sections.
4646

47-
Most components should use the compose framework as it offers the comprehensive set of patterns like tokens and slots, but if you're creating a simple component that doesn't require those patterns, there's a lighter pattern called [stagedComponent](./packages/framework/use-slot/src/stagedComponent.ts). The stagedComponent pattern splits up the render function into two stages. Stage 1 handles building props and hook calls (best to separate the hook calls from the render tree since they rely on call order). Stage 2 returns the actual element tree, any conditional branching should happen here (Icon is a good example of using stagedCompoenent).
47+
Most components should use the compose framework as it offers the comprehensive set of patterns like tokens and slots, but if you're creating a simple component that doesn't require those patterns, there's a lighter pattern called [stagedComponent](./packages/framework-base/src/component-patterns/stagedComponent.ts). The stagedComponent pattern splits up the render function into two stages. Stage 1 handles building props and hook calls (best to separate the hook calls from the render tree since they rely on call order). Stage 2 returns the actual element tree, any conditional branching should happen here (Icon is a good example of using stagedCompoenent).
4848

4949
1. Create a new directory in of these two locations, depending on your component:
5050

@@ -82,7 +82,7 @@ Reach out to Samuel Freiberg with any questions related to E2E testing.
8282

8383
## Adding native code to your new component
8484

85-
Through the power of [Native Modules](https://reactnative.dev/docs/0.74/native-modules-intro), we are able to create components that are comprised of native platform code, rather than JS. This is particularly useful if you want platform specific behavior, or if you want a component that feels much more aligned to it's specific platform. The downside is you must implement the Native module for every platform you wish to support. It's worth investigating whether you truly need a native module, or if a more cross platform JS implementation is the better approach.
85+
Through the power of [Native Modules](https://reactnative.dev/docs/turbo-native-modules-introduction), we are able to create components that are comprised of native platform code, rather than JS. This is particularly useful if you want platform specific behavior, or if you want a component that feels much more aligned to it's specific platform. The downside is you must implement the Native module for every platform you wish to support. It's worth investigating whether you truly need a native module, or if a more cross platform JS implementation is the better approach.
8686

8787
There are a few caveats to know of adding a native module to a FluentUI React Native component:
8888

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "fix dead links in markdown files",
4+
"packageName": "@fluentui-react-native/avatar",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "fix dead links in markdown files",
4+
"packageName": "@fluentui-react-native/badge",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "tighten up typing for framework, fixing the resulting errors",
4+
"packageName": "@fluentui-react-native/button",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "fix dead links in markdown files",
4+
"packageName": "@fluentui-react-native/checkbox",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "fix dead links in markdown files",
4+
"packageName": "@fluentui-react-native/chip",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "tighten up typing for framework, fixing the resulting errors",
4+
"packageName": "@fluentui-react-native/composition",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix use-slot to use new rendering patterns",
4+
"packageName": "@fluentui-react-native/dropdown",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "tighten up typing for framework, fixing the resulting errors",
4+
"packageName": "@fluentui-react-native/experimental-checkbox",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "tighten up typing for framework, fixing the resulting errors",
4+
"packageName": "@fluentui-react-native/experimental-expander",
5+
"email": "jasonmo@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

0 commit comments

Comments
 (0)