The Wayback Machine - https://web.archive.org/web/20201130154240/https://github.com/kriasoft/react-starter-kit/issues/226
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title not working on server side #226

Open
vitaminwater opened this issue Aug 19, 2015 · 8 comments
Open

Title not working on server side #226

vitaminwater opened this issue Aug 19, 2015 · 8 comments

Comments

@vitaminwater
Copy link

@vitaminwater vitaminwater commented Aug 19, 2015

There is a typo in index.html

<title><%- title %></title>

instead of:

<title><%= title %></title>

notice the '=' instead of '-'

But the title still doesn't show up in the generated content.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@rodolfo2488
Copy link

@rodolfo2488 rodolfo2488 commented Aug 19, 2015

I think it uses https://lodash.com/docs#template

// using the "interpolate" delimiter to create a compiled template
var compiled = _.template('hello <%= user %>!');
compiled({ 'user': 'fred' });
// → 'hello fred!'

// using the HTML "escape" delimiter to escape data property values
var compiled = _.template('<b><%- value %></b>');
compiled({ 'value': '<script>' });
// → '<b>&lt;script&gt;</b>'
@vitaminwater
Copy link
Author

@vitaminwater vitaminwater commented Aug 19, 2015

Well that's is strange then because in index.html it uses the <%= %> way of doing for all other variables.

@vitaminwater
Copy link
Author

@vitaminwater vitaminwater commented Aug 19, 2015

oops, hadnt read carefully.

anyway the title bug was not related to the "typo" as it wasn't working anyway.

any idea why it is not showing up in the html generated by the server ?

I'm just calling:

this.context.onSetTitle('[blahblah title]');

in componentDidMount in a classe with the withContext decorator.

@koistya
Copy link
Member

@koistya koistya commented Aug 19, 2015

@vitaminwater componentDidMount() is never called on the server (during server-side rendering). You may want to use componentWillMount() instead for that purpose.

@vitaminwater
Copy link
Author

@vitaminwater vitaminwater commented Aug 19, 2015

Still not working:(

@rodolfo2488
Copy link

@rodolfo2488 rodolfo2488 commented Aug 19, 2015

can you paste your class here?

@vitaminwater
Copy link
Author

@vitaminwater vitaminwater commented Aug 19, 2015

After deploying on my server, it works.

I'm building on this server with npm run build -- release and run with forever restart build/server.js

So looks like the bug is only when running with npm start

@aayler
Copy link

@aayler aayler commented Sep 19, 2015

I have the same issue, but with the call to this.context.onSetTitle( this.props.title ) in render(). The title reads 'undefined' but I've specified a title in the jade template.

@vitaminwater : can you please share how you called the method in your component? I tried the run build and forever combination that you mentioned but without success ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.