Allow setting user
as a prop (#1832)
Add `user` as a prop to `TldrawEditor` ### Change Type - [x] `patch` — Bug fix
This commit is contained in:
parent
e3b07631ce
commit
3bde22a482
2 changed files with 8 additions and 1 deletions
|
@ -1997,6 +1997,7 @@ export interface TldrawEditorBaseProps {
|
|||
onMount?: TLOnMountHandler;
|
||||
shapeUtils?: readonly TLAnyShapeUtilConstructor[];
|
||||
tools?: readonly TLStateNodeConstructor[];
|
||||
user?: TLUser;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
|
|
@ -98,6 +98,11 @@ export interface TldrawEditorBaseProps {
|
|||
* A classname to pass to the editor's container.
|
||||
*/
|
||||
className?: string
|
||||
|
||||
/**
|
||||
* The user interacting with the editor.
|
||||
*/
|
||||
user?: TLUser
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,10 +131,11 @@ export const TldrawEditor = memo(function TldrawEditor({
|
|||
store,
|
||||
components,
|
||||
className,
|
||||
user: _user,
|
||||
...rest
|
||||
}: TldrawEditorProps) {
|
||||
const [container, rContainer] = React.useState<HTMLDivElement | null>(null)
|
||||
const user = useMemo(() => createTLUser(), [])
|
||||
const user = useMemo(() => _user ?? createTLUser(), [_user])
|
||||
|
||||
const ErrorFallback =
|
||||
components?.ErrorFallback === undefined ? DefaultErrorFallback : components?.ErrorFallback
|
||||
|
|
Loading…
Reference in a new issue