Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marcolink/use-render-component

⚛️ Expose setter functions for your react component props - more of a playground than anything helpful
https://github.com/marcolink/use-render-component

Last synced: 27 days ago
JSON representation

⚛️ Expose setter functions for your react component props - more of a playground than anything helpful

Awesome Lists containing this project

README

        

# use-render-component

Did you always wanted to expose a setter/getter for any of your components props?

### Example
```typescript
import * as React from "react";

type ButtonProps = {
label: string,
onClick?: () => void,
};

const Button: React.FC = (props) => {
return {props.label};
};

const App: React.ReactNode = () => {
const button = useRenderComponent(Button, {label: "click me"});
button.updateProp("onClick", ()=> button.updateProp("label", "clicked"));
return button.component;
};

```