Skip to content

Conversation

josiasds
Copy link
Member

When using Redux, the main component exposed to the API is a function that returns a React component. This PR allows rendering of simple React components. The more advanced functionality of using a generator function is essential for tools like redux and react-router.

In the dummy app, along with App component (that uses Redux), ServerApp and ClientApp now also export a simple React component, HelloWorld. The component can be rendered by the client or using server side rendering, as demonstrated in the index page.

To test, run the dummy app and export some components with and without Redux, in both client an server apps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks excellent. CC: @alexfedoseev @samnang. This looks like a good way to determine if the component is a React.Component. We need to make sure this works for createClass as well as the ES6 class definition. Another option could be to check if the object has a property called render that's a function. We also need to consider if the React API might change in ways that would break this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a good point. We need to make sure it work with React.createClass as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could confirm that it doesn't work with createClass. http://jsbin.com/relijopuqi/edit?js,console,output

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petehunt What's the best, most canonical, way to decide if we have a real React Component? (class or generated)? Something that will work as React evolves...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justin808 justin808 changed the title Allow rendering of React components without Redux Allow rendering of React components without using a generator function (just direct React Component) Sep 10, 2015
@justin808
Copy link
Member

@josiasds Let's get this wrapped up. I want to push this to rubygems ASAP! Lots of people ready to use this! 👍 :-)

- Add support to React components generated with React.createClass()
- Add “generator” property to allow creating a React component via a
function
- Add HelloES5 component to the dummy application
@josiasds
Copy link
Member Author

@justin808 Ready!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static?
def self.render_js...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the signature so it's clear that you're not passing the real props.

def render_js_react_element(react_component_name, props_name)

- Renaming Ruby variables to snake case
- Make ReactRenderer#render_js_react_element a class method
- Improve generated JS code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment above this line:

    # create the server generated html of the react component with props

@justin808
Copy link
Member

See #20

@justin808 justin808 closed this Sep 13, 2015
AbanoubGhadban pushed a commit that referenced this pull request Sep 25, 2025
Add protocol versions and scheduled workers restarts
AbanoubGhadban pushed a commit that referenced this pull request Sep 26, 2025
Add protocol versions and scheduled workers restarts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants