Last active
September 18, 2018 07:22
-
-
Save eric-burel/3ddd0186734c4f5f8aae0c2ec7cc89e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package 1 - "my-basic-ui" | |
const MyBasicButton = ({onClick, children}) => ( | |
<button onClick={onClick}> | |
{children} | |
</button> | |
) | |
// Tell other packages they can use your component | |
// under the name "Button" | |
registerComponent({ | |
name: 'Button', | |
component: MyBasicButton | |
}) | |
// Package 2 - "my-better-ui" | |
// We replace the Button component to improve it | |
const MyStyledButton = ({onClick, children}) => ( | |
<button className="btn" onClick={onClick}> | |
{children} | |
</button> | |
) | |
replaceComponent({ | |
name:'Button', | |
component: MyStyledButton | |
}) | |
// Package 3 - "my-app" | |
// Example usage. Thanks to registration, we can change the Button style | |
// without touching this code at all | |
const MyInterface = () => ( | |
<Components.Button onClick={() => console.log('click')}> | |
Click Me! | |
</Components.Button> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment