https://github.com/sagemathinc/cocalc
Raw File
Tip revision: be6091d55c6ae6ca4c794b1a22d8254ef7e41f44 authored by John Jeng on 02 August 2019, 17:36:39 UTC
Catch the null case for params
Tip revision: be6091d
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