/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/docs/Record.Factory.mdx
46 строк
1 KB
Julien Deniau
Doc as mdx instead of export from .d.ts file (#2104)
24 май 2025, 00:47
Не верифицирован
24 май 2025, 00:47
21de701
Код
Авторство
О чём код?
import Repl from '@/repl/Repl.tsx'; import CodeLink from '@/mdx-components/CodeLink.tsx'; # Record.Factory A Record.Factory is created by the `Record()` function. Record instances are created by passing it some of the accepted values for that Recordtype: <Repl defaultValue={`// makePerson is a Record Factory function const makePerson = Record({ name: null, favoriteColor: 'unknown' }); // create a Record instance makePerson({ name: 'Alan' });`} /> Note that Record Factories return `Record<TProps> & Readonly<TProps>`, this allows use of both the Record instance API, and direct property access on the resulting instances: <Repl defaultValue={` const makePerson = Record({ name: null, favoriteColor: 'unknown' }); const alan = makePerson({ name: 'Alan' }); // Use the Record API 'Record API: ' + alan.get('name') + "\\n" + // Or direct property access (Readonly) 'property access: ' + alan.name; `} /> ## Construction <MemberLabel label="Record.Factory" /> <Signature code={`Record.Factory<TProps extends object>( values?: Partial<TProps> ): RecordOf<TProps>`} /> ## Members <MemberLabel label="displayName" /> The name provided to `Record(values, name)` can be accessed with `displayName`. <Signature code="displayName: string" />