-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept type-keyed react render functions #5244
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
Signed-off-by: Michael Darr <[email protected]>
This reverts commit ef390cc.
|
Signed-off-by: Michael Darr <[email protected]>
Status
The contents of this PR represent an in-progress implementation of a proposal. If it is decided to move forward in this direction, tests, a changeset, and additional documentation will be written and added to this PR.
Description
These changes allow type-specific render functions to passed into the
Editable
component directly. TherenderElement
andrenderLeaf
properties now accept either a single render function (the current standard) or an object mapping thetype
property of the relevantDescendant
to its render function.Example
This PR uses the new pattern for element renderers in the
inlines example
:custom-types.d.ts
inlines.tsx
Context
In my experience, defining and maintaining Text and Element render functions is tedious. As seen in several of the examples, these render functions are usually just a huge, awkward
switch
statements.These changes provide a more direct, less cumbersome method of passing typed render functions to Slate. Care has been taken to make these changes non-breaking.
Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)