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;
|
onMount?: TLOnMountHandler;
|
||||||
shapeUtils?: readonly TLAnyShapeUtilConstructor[];
|
shapeUtils?: readonly TLAnyShapeUtilConstructor[];
|
||||||
tools?: readonly TLStateNodeConstructor[];
|
tools?: readonly TLStateNodeConstructor[];
|
||||||
|
user?: TLUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @public
|
// @public
|
||||||
|
|
|
@ -98,6 +98,11 @@ export interface TldrawEditorBaseProps {
|
||||||
* A classname to pass to the editor's container.
|
* A classname to pass to the editor's container.
|
||||||
*/
|
*/
|
||||||
className?: string
|
className?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user interacting with the editor.
|
||||||
|
*/
|
||||||
|
user?: TLUser
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,10 +131,11 @@ export const TldrawEditor = memo(function TldrawEditor({
|
||||||
store,
|
store,
|
||||||
components,
|
components,
|
||||||
className,
|
className,
|
||||||
|
user: _user,
|
||||||
...rest
|
...rest
|
||||||
}: TldrawEditorProps) {
|
}: TldrawEditorProps) {
|
||||||
const [container, rContainer] = React.useState<HTMLDivElement | null>(null)
|
const [container, rContainer] = React.useState<HTMLDivElement | null>(null)
|
||||||
const user = useMemo(() => createTLUser(), [])
|
const user = useMemo(() => _user ?? createTLUser(), [_user])
|
||||||
|
|
||||||
const ErrorFallback =
|
const ErrorFallback =
|
||||||
components?.ErrorFallback === undefined ? DefaultErrorFallback : components?.ErrorFallback
|
components?.ErrorFallback === undefined ? DefaultErrorFallback : components?.ErrorFallback
|
||||||
|
|
Loading…
Reference in a new issue