UNPKG

@react-three/uikit

Version:

Build performant 3D user interfaces with react-three-fiber and yoga.

23 lines (22 loc) 837 B
import { jsx as _jsx } from "react/jsx-runtime"; import { createContext, useContext } from 'react'; const DefaultPropertiesContext = createContext(undefined); export function useDefaultProperties() { return useContext(DefaultPropertiesContext); } export function DefaultProperties(properties) { const existingDefaultProperties = useContext(DefaultPropertiesContext); const result = { ...existingDefaultProperties }; for (const key in properties) { if (key === 'children') { continue; } //TODO: this is not correctly merged but rather overwritten const value = properties[key]; if (value == null) { continue; } result[key] = value; } return _jsx(DefaultPropertiesContext.Provider, { value: result, children: properties.children }); }