mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
17 lines
455 B
JavaScript
17 lines
455 B
JavaScript
import React, {useMemo} from 'react';
|
|
|
|
import ls from './Field.less'
|
|
import cx from 'classnames';
|
|
|
|
export const FieldId = React.createContext(-1);
|
|
|
|
let ID_GENERATOR = 0;
|
|
|
|
export default function Field({active, name, ...props}) {
|
|
|
|
const fieldId = useMemo(() => 'Field_' + (ID_GENERATOR++), []);
|
|
|
|
return <FieldId.Provider value={fieldId}>
|
|
<div className={cx(ls.root, active&&ls.active)} data-field-name={name} {...props} />
|
|
</FieldId.Provider>;
|
|
}
|