
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@fluentui-react-native/merge-props
Advanced tools
Utility for merging props with styles and caching style combinations
Utilities for merging styles and props (which contain styles)
The mergeProps
routine handles merging props together. Generally this is a standard per property merge identical to the behavior of Object.assign
with the following two exceptions:
props.style
will be merged using mergeStyle
above, including caching the resolved stylesprops.className
will be joined together using spaces as a delimiter.Styles are defined using the standard react-native pattern and will be merged in a way that maintains object identity where possible.
This is a copy of the StyleProp definition from react-native
. This is copied primarily in the case where it is used in web code where adding a dependency on the react-native
package itself is not desireable.
The StyleProp pattern itself is allows a style to be provided as a style or a recursive array of styles. So the following pattern is allowed:
props = {
style: [{ ...style1 }, [{ ...style2 }, { ...style3 }, [{ ...style4 }]], { ...style5 }],
};
In this model merging styles can be effectively deferred by the following:
const styleToMerge = { ...values };
props.style = [props.style, styleToMerge];
This routine merges one or more react-native styles together. The inputs are styles in the StyleProp
format referenced above. The various input styles will be flattened and merged together to produce a single non-flattened output style.
function mergeStyles<T>(...styles: StyleProp<T>[]): T;
This routine has a built-in caching layer that will attempt to ensure that object identity remains consistent. This means that style A + style B, where the references to A and B are the same, will always produce object C, where the reference will also be the same.
FAQs
Utility for merging props with styles and caching style combinations
The npm package @fluentui-react-native/merge-props receives a total of 1,105 weekly downloads. As such, @fluentui-react-native/merge-props popularity was classified as popular.
We found that @fluentui-react-native/merge-props demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.