https://github.com/sagemathinc/cocalc
Raw File
Tip revision: 6a3a576573bd1e92e7aacf3a1356842bf5f96e43 authored by Harald Schilly on 16 April 2021, 07:53:43 UTC
jupyter/format magics: process each line individually -- #5290
Tip revision: 6a3a576
Writing Components.md
## `rclass`

### Normal Usage
Just use as if your object was being passed to `React.createClass()`

### Enhanced Usage
However, it can also be passed a function which takes in properties only known at runtime. This allows you to do things like pass in names of stores which are generated at run time.
```coffee
ProjectPage = rclass ({project_store_name, another_store_name}) ->
    reduxProps:
        "#{project_store_name}"
            active_tab : rtypes.string
            open_files : rtypes.immutable
        "#{another_store_name}"
            first_name : rtypes.string
            last_name  : rtypes.string

    propTypes:
        project_id : rtypes.string

    render: ->
        <p>Example!</p>

ReactDOM.render(<ProjectPage project_store_name={name} another_store_name={other_name} project_id={project_id})
```
back to top