microsoft / microsoft/fluentui
Update to use maps instead of stringifying json for values
Open
@mltejera is already working on this.
Since Dec 6, 2023.
Component: Nav
Fluent UI react-components (v9)
Resolution: Soft Close
- Dominant language
- TypeScript
- Stars
- 20.3k
- Forks
- 2.9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 46
Description
Update nav to use maps for keys instead of stringifying json.
@spmonahan did me a solid by coding out a great tutorial/example.
https://github.com/microsoft/fluentui/pull/29867#discussion_r1409940094
type MyComplexKey = {
value: number;
type?: string;
}
// Record is just an Object so it's keys are relatively restricted
type MyRecord = Record<MyComplexKey, number>;
// Map can use any valid JS object as a key
type MyMap = Map<MyComplexKey, number>;
type MyReactProps = {
value: MyComplexKey;
}
const MyReactComponent = (props: MyReactProps): void => {
// We can even infer the type if we want
const myInternalThing: Map<typeof props.value, number> = new Map();
myInternalThing.set(props.value, 1);
}
// And it seems `unknown` works okay with Map too!
type MyUnknownMap = Map<unknown, number>;
const unknownMap: MyUnknownMap = new Map();
unknownMap.set(1, 2);
unknownMap.get(1);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.