danott / react-rails-form-helpers

Components for composing forms targeted at Rails
MIT License
81 stars 18 forks source link

Modernize React idioms #17

Open danott opened 4 years ago

danott commented 4 years ago

We're using the legacy context API. It'd be worth modernizing to the latest and greatest React idioms to make this useful into the future.

hibachrach commented 4 years ago

Was playing around with this. Perhaps it's my inexperience with class components, but I'm unsure of how we can use the new context API with an Array value without always triggering a re-render. Those docs suggest putting the context into the state solves the problem, but I don't know in which lifecycle method it would be best to update the state.

But maybe none of this is a significant issue if there are no actual changes in the DOM to reconcile.

danott commented 4 years ago

I'd be inclined to lean into the assumption that React is fast until proven slow.

I'm coming from a background of replacing jQuery("#some-node").html("<div>Some new html!</div>") with ReactDOM.render(<SomeNewHtml />, document.getElementById("some-node")), and I've gotta imagine it can't be worse then it's predecessor? 😆