How to use react in phoenix

my assets/js/app.js file:
import React from ‘react’;
import ReactDOM from ‘react-dom’;

class App extends React.Component {
render() {
return (


Hello world!


)
}
}

ReactDOM.render(
,
document.getElementById(‘app’),
);

my index.html.eex file:

but I can’t see hello,world in my brower.

@yyellowsun, welcome to the community!

Please provide a sample public repo of your actual repo or some example of your actual code. The above doesn’t help much to understand where you’re facing an issue.

To make this simpler, I’m providing some sample articles about integrating react with elixir and phoenix:

https://itnext.io/add-react-to-phoenix-92c590fbbc7f

https://betterprogramming.pub/using-react-17-with-phoenix-1-5-1b445526c739

https://medium.com/@resir014/a-phoenix-react-initial-setup-that-actually-works-c943e48f1e9e

Also, in the forum itself, found references of react questions:

Hope, this guides in your adventure! Have fun!

Thanks,It’s my first time to use this forum.And I found my issues.I just follow a v1.3phoenix tutorial,but using a v1.5phoenix.

1 Like