-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
43f99ac
to
e07c287
Compare
gulp/plugins/gulp-react-docgen.js
Outdated
@@ -29,9 +29,7 @@ export default () => | |||
cb(null, infoFile) | |||
} catch (err) { | |||
const pluginError = new gutil.PluginError(pluginName, err) | |||
pluginError.message += `\nFile: ${file.path}.` | |||
pluginError.message = err.stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you also want the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message is included at the top of the stack.
* Test/is conformant (#20) * test(isConformant): begin update to jest * fix(lib): remove base component * -convert the isConformant test to jest -adjust the isConformant and assertNodeContains according to the latest changes of the crateComponent helper -changed the componentClassName in the info file following the BEM naming convention -added some required additional static fields in the result component in the createComponent helper, which are used in the tests * -fixed bug in the Image component for user defined classNames to be applied on the root component * introduce alternative approaches to base component applied to Image * introduce improvements for HOC approach
08a3f1f
to
9b5ca58
Compare
/** | ||
* An image is a graphic representation of something. | ||
*/ | ||
class ImageCreateComponent extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to extend here the React.Component, and not the BaseComponent? Is this a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
There has been a lot of conversation around this. The majority of participants in the conversation are leaning away from the createComponent() HOC. The preference is toward a pattern where the render method of a component is responsible for wiring the base functionality of the component. // better :)
const Image = (props) => {
return (
<Render
rules={imageRules}
props={props}
render={({ classes }) => <img className={classes.root} />}
/>
)
}
// worse :/
const Image = (props) => {
const { classes } = this.props
return <img className={classes.root} />
}
export default createComponent(Image, { rules }) Why? When the functionality is added from within the component vs from outside the component:
For these reasons, I'll add the // best?
const Image = (props) => {
return renderComponent({ rules, props }, ({ classes }) => (
<img className={classes.root} />
))
} |
If we'll consider the first approach - one thing that would like to clarify for myself to get the full picture.
Would we need to mock the module of
Thanks! |
just few words around the following goal: 👍 Allow us to add static members and methods to components It looks like even with render function approach - or, generally speaking, with any approach taken - we would be able to cover this aspect by introducing additional function that should be used to provide static members to component. Specifically, this is how the import { renderWithStyles, withStaticMembers } from './core'
class MyComponent {
render = () => renderWithStyles((theme, classNames) => (<div className={classNames}> ... <>);
}
export default withStaticMembers(MyComponent); Please, note that, essentially, any other approach that is suggested so far (but, I might bet, literally, any) could use the same pattern. With that being said, it seems that requirement of 'having general functionality to introduce static methods' is something that shouldn't be a decisive factor, due to this moment could be addressed pretty easily as a separate piece of common logic. Also, if would take into account that there are conformance tests that will check whether specific properties are present or not for the exported component, the approach when we will divide common rendering aspects (with |
…unction -updated isConformance test to work according to the latest changes -added TODOs for the future work
Agreed, removed. |
@mnajdova has merged an update here that implements the We will merge this soon and use this pattern as our approach. We are open to changes, but they need to prove material superior to this one. |
I've been lurking and generally following the conversation here until I have some extra time to throw at contributing. I really like this final solution. It cleans a lot of things up. Another benefit I think we get here is a pattern that is easier to follow for new contributors. |
Hmm. How does this split out state from the view? Are they still intertwined? Where would state be managed? I preferred the
The way I see props flowing is as such: user props => optional state transforms => styling => final view props used for view The "view" could be enforced as a functional thing, implying that both 1. it is the simplest logic possible for the render code, and 2. we could literally call the function to avoid adding any view overhead to reduce the react wrapper code. This means for partners, if you want to re-scaffold a component to change around the composed subcomponent orientation, (e.g.) a chevron icon moves to the far side or near side) it's easy. Just create a component that provides all the same values except a new view. You could technically even expose an augmentation API surface to take an existing component and easily replace parts of it. I like this because it makes it easy to "glue" together separate pieces, rather than to create monolithic components that manage state, props, and rendering all in one place. Because UIComponent based on React.Component, when and how would |
Guys, I have made some changes in the implementation of the |
f4eb5e5
to
339716d
Compare
We should be able to handle calling any function with a different context using function methods like |
42918ad
to
d3bbc9a
Compare
* -transpaling the code from the components before providing it to the react-docgen parse * wip * -fixed error for files generating multiple components in react-docgen parse * -implemented custom resolver and added isUiComponentClass checker -changed UIComponent to invoke the renderComponent method instead of passing it as callback in order to have this in the context of the method -small fixes in the components * -bug fixes * rebase to feat/base-component and fix issues
0ceab5c
to
8a81a54
Compare
8a81a54
to
c9cdb1f
Compare
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
=========================================
Coverage ? 67.33%
=========================================
Files ? 66
Lines ? 1047
Branches ? 190
=========================================
Hits ? 705
Misses ? 339
Partials ? 3
Continue to review full report at Codecov.
|
I've finally caught up with all the merged PRs. All components now extend the |
Most UI components require a common set of behavior such as styling and accessibility. There should be a single point of responsibility for implementing these behaviors.
Goals
Restrictions
Proposals
We explored the following approaches. The below code snippets simplified for ease of review.
createComponent(Component, config)
A HOC that wraps the provided component and passes features through props.
<Render />
A component that takes config as props and computes all the values necessary to create your component.
Directly render consumers
Directly import context consumers and use them in the render method to access the CSS-in-JS renderer and theme.
HOC Context
A function to be returned in the render method. Calls back with the theme. Implemented by using a theme consumer in a function.
Others
We tested and ruled out these approaches as they rely on the legacy context API and private fela APIs.
Conclusions